General question: when I make a graph component with, say, a lot of nested calculations going on, the calculator or graph component is really really slow/sluggish. Would putting some of that calculating (by using simpleFunction and a bunch of nested whens) in the CL speed up the response?
Definitely a dev question. @Jay?
Also, could you share your activity?
There are quite a few things you could do with varying effect to speed up interactions. An interaction designer like @aknauft can be more thorough, but off the top of my head:
- using parametrics, polygons, or images. Especially to replace graphs that use the implicit plotter
- avoiding really long lists that drive calculations
- reducing computations on lists that will update constantly
- avoiding nesting functions too deeply
- Conditionally disabling functions from running when they aren’t in use.
Basically keep too many things from updating constantly.
On the CL end, moving calculations there can take a load off of graphs, but we’ve found that constantly sending values from graphs to CL and back is actually much slower. If you’re going to do calculations in CL, a safe bet is to make sure all of the info is flowing in one direction (e.g. variables defined in CL drive both the raw number sinks and the computed values via simpleFunction). Then again, if the values coming from the graph into CL aren’t changing you probably wont run into it. But the only way to see if anything makes a difference is to test (preview) often.
Jay hit everything I would have said for keeping your graphs speedy! Basically, “avoid things that make it slow” Nested summations are my favorite way to slow down a graph, so definitely try to avoid those.
I’ll repeat his comment about keeping things flowing in one direction: If your function has five conditional branches, you could turn that into five
when statements in CL — but if the CL is still pulling values out of the graph for each
when branch, I wouldn’t actually expect a speed boost. On the other hand, if the conditions are set by something the CL has more immediate access too (like, a button’s press count), it could make sense to do the condition fully in CL and pass down a final result into the graph.
Thanks everybody! I got rid of some conditions and changed my circles to parametrics, and things respond much better now!