Message Boards Message Boards

Determine Timing of Dynamic Refreshes?


How would one determine the efficiency of a code for which drawing a graphic is the most expensive step?

I am investigating various methods to change a graphics object in a Dynamic[Graphics[...]]

For example,

positions = RandomReal[{-1, 1}, {200, 2}];
colors = RandomColor[Length[positions]];
radii = RandomReal[{0, .1}, Length[positions]];
Dynamic[Graphics[MapThread[{#3,Disk[#1,#2]}&,{positions, radii, colors}]]

I am curious how much time each Dynamic refresh takes. I tried using EvaluationData, but couldn't make it work. I wonder if there is a way to create a "DynamicEvaluationMonitor"?

POSTED BY: W. Craig Carter
3 months ago

I think it has just lower bound on time but not the upper bound, because you cannot force computer to perform some operations faster than it physically can. On the other hand if the computer is fats enough, it will not shorten time below designated, like here and go steady at that rate:

Dynamic[Refresh[DateString[], UpdateInterval -> 1]]

But I am just guessing.

POSTED BY: Sam Carrettie
3 months ago

Thanks Sam, That makes sense, but I don't think it is quite what I was looking for.

In my case, I have several alternatives of how to construct the Graphics. The above example is a proxy for a more complicated objective.

For the example, I am thinking of ways that I don't recompute the Graphics boxes if the positions and the radii don't change very rapidly compared to the colors. I'd like to do some profiling on the various methods. I am looking for speed-ups that are on the order of milliseconds.

This isn't terribly important, but I was just wondering how I might do the equivalent or RepeatedTiming for a Dynamic Object.

POSTED BY: W. Craig Carter
3 months ago

Group Abstract Group Abstract