Profiling Direct2D Performance

We’ve just updated to the juce develop tip, it’s made a fair improvement but we’ve still got situations where the UI is very laggy.

We’re building with both JUCE_ETW_TRACELOGGING=1 and JUCE_DIRECT2D_METRICS=1.

I’m able to view the trace log in “Windows Performance Analyser” but the output isn’t that useful as there doesn’t seem to be any good time summary.

I think JUCE_DIRECT2D_METRICS would be more useful but how do I view the output of this?

If I wanted this kind of info on macOS I’d use signposts as it gives me min/max/avg/sd measurements. I’m looking for something similar here.

I can also share the Waveform binary if you’d like to see the performance yourself.

On MacOS the best thing you can do is integrate Perfetto and use it. This has shown me so many interesting details about things. I guess that’s what you might’ve meant with signposting, since this is also quite easy to do with Perfetto calls in the right places…

Signposting is the same, it just uses Instruments instead.

But that’s not what I’m talking about here. There’s a ton of profiling built in to the Direct2D juce code (on Windows only), I just want to know how to access it.

Perfetto can’t open the log files created by ETW. Maybe there’s a conversion tool?

Ah, roger that, sorry for injecting a non-sequitur.

No problem, it might be useful to others.
I was just wondering if the juce team or @matt have tooling they’ve used for this.

I’ll put something together.

Matt

2 Likes

Hi everyone-

This needs more TLC, but this should at least work with JUCE develop.

Build your binary with #define JUCE_DIRECT2D_METRICS=1.The renderer will create a named pipe server to report metrics. Here’s a prebuilt app that reads and displays the metrics:

[Dropbox](https://Direct2D Metrics app 1.0.2)

Here’s the source:

To use the metrics app, just display your window and bring it to the foreground. The app should discover any named pipes and show the metrics:

Click the dropdown at the top of the window to select the window you want to observe. The app shows statistics for all the various drawing operations the renderer can perform; typically I look for excessive standard deviation.

Times are shown in milliseconds.

The “%” column shows the relative amount of time spent on each operation in a single frame. For example, in the screenshot above, the renderer is spending about 56% of each frame calling EndDraw on average.

Hope that helps-

Matt

6 Likes

Super cool! Nice one, Matt.