# Profiling Direct2D Performance

**URL:** <https://forum.juce.com/t/profiling-direct2d-performance/65031>\
**Category:** Direct2D\
**Created:** [January 28, 2025, 12:15pm UTC](https://forum.juce.com/t/profiling-direct2d-performance/65031 "2025-01-28T12:15:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dave96](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/dave96/32/8487_2.png) [@dave96](https://forum.juce.com/u/dave96)\
**Post date:** [January 28, 2025, 12:15pm UTC](https://forum.juce.com/t/profiling-direct2d-performance/65031/1 "2025-01-28T12:15:17Z")

</div>

We’ve just updated to the juce [develop tip](https://github.com/juce-framework/JUCE/commit/da45497a3dc91a756a4460388a97b14c3b09b1d0), 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.

---

<div class="post-metadata">

**Author:** ![ibisum](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ibisum/32/21288_2.png) [@ibisum](https://forum.juce.com/u/ibisum)\
**Post date:** [January 28, 2025, 12:56pm UTC](https://forum.juce.com/t/profiling-direct2d-performance/65031/2 "2025-01-28T12:56:59Z")

</div>

> [@dave96](#):
>
> 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.

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…

---

<div class="post-metadata">

**Author:** ![dave96](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/dave96/32/8487_2.png) [@dave96](https://forum.juce.com/u/dave96)\
**Post date:** [January 28, 2025, 12:59pm UTC](https://forum.juce.com/t/profiling-direct2d-performance/65031/3 "2025-01-28T12:59:44Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ibisum](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ibisum/32/21288_2.png) [@ibisum](https://forum.juce.com/u/ibisum)\
**Post date:** [January 28, 2025, 1:23pm UTC](https://forum.juce.com/t/profiling-direct2d-performance/65031/4 "2025-01-28T13:23:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dave96](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/dave96/32/8487_2.png) [@dave96](https://forum.juce.com/u/dave96)\
**Post date:** [January 28, 2025, 1:26pm UTC](https://forum.juce.com/t/profiling-direct2d-performance/65031/5 "2025-01-28T13:26:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![matt](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/matt/32/18340_2.png) [@matt](https://forum.juce.com/u/matt)\
**Post date:** [January 28, 2025, 4:47pm UTC](https://forum.juce.com/t/profiling-direct2d-performance/65031/6 "2025-01-28T16:47:07Z")

</div>

I’ll put something together.

Matt

---

<div class="post-metadata">

**Author:** ![matt](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/matt/32/18340_2.png) [@matt](https://forum.juce.com/u/matt)\
**Post date:** [January 28, 2025, 11:06pm UTC](https://forum.juce.com/t/profiling-direct2d-performance/65031/7 "2025-01-28T23:06:16Z")

</div>

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://www.dropbox.com/scl/fi/x0vhzy4hh4gys343mxe5w/Direct2DMetrics.exe?rlkey=8spjosz3lm8smlpefwm80rspc&dl=1)]([https://Direct2D](https://Direct2D) Metrics app 1.0.2)

Here’s the source:

> **[MESCAL/metrics at main · 7StringSoftware/MESCAL](https://github.com/7StringSoftware/MESCAL/tree/main/metrics)**
>
> Additional Direct2D features for JUCE 8. Contribute to 7StringSoftware/MESCAL development by creating an account on GitHub.

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:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/juce/original/3X/8/0/803e9ac9ee6567bf2140924fa9e99ff0987f706a.png)

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

---

<div class="post-metadata">

**Author:** ![ibisum](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ibisum/32/21288_2.png) [@ibisum](https://forum.juce.com/u/ibisum)\
**Post date:** [January 30, 2025, 10:13am UTC](https://forum.juce.com/t/profiling-direct2d-performance/65031/8 "2025-01-30T10:13:45Z")

</div>

Super cool! Nice one, Matt.
