Clean way to measure drawing throughput?


When my ComponentPeer paints the RectangleList of invalid areas, I want to calculate the drawing throughput measured in pixels per second. The number of pixels should be equal to the sum of the areas of the rectangles in the RectangleList of the area requiring update (usually retrieved from the operating system for example GetUpdateRgn() on Windows). The time spent should be measured by subtracting the value of the performance counter before from after the call to component->paintEntireComponent() in ComponentPeer (or something similar). I would like to keep a small array of moving history of these pixel/time value pairs so I can display the throughput in a label or something.

It seems there isn’t enough API exposed in LowLevelGraphicsContext to extract the RectangleList, and certain members in ComponentPeer are non virtual, so my question is what would be the cleanest way of doing this, preferably without changing any Juce code (i.e. some subclassing) but if I do have to change Juce code what’s the minimal amount of changes?


Damn right there isn’t! CoreGraphics provides no access to the clip region, except for its bounding box. The software renderer might not be using a rectangle list, it could be an edge table.

Good luck with whatever you’re trying to do, but I think a far saner approach would be to create a test harness for the thing you’re trying to optimise, in which you’d perform a repeatable, controlled operation to an off-screen image, and measure its performance. That’ll give you a much more meaningful result.