How would I accurately benchmark the time it takes...
# compose
z
How would I accurately benchmark the time it takes to draw to a canvas? Out of curiosity I want to see how much of a difference comes from using a single custom shader vs multiple overlapping brushes to achieve the same effect.
đź‘€ 1
s
You can analyze performance by capturing system traces, which also include rendering information. I usually use https://ui.perfetto.dev/ to view trace reports. First, find your app's process name. Then, focus on the main thread and render thread rows in the trace. The main thread shows how long it takes to issue drawing commands to the renderer, it only schedules them. The actual rendering happens on the render thread. This part is highly device-specific. Some devices provide detailed trace data, while others show very limited information. On some devices, you can adjust this behavior in Developer Settings. In these trace sections, you can observe differences between drawing operations like brush gradients and custom shaders. To make trace analysis easier, you can add your own trace labels using the androidx.tracing library. Just wrap your code blocks with a trace label, and they'll appear clearly in the trace.
*for Android platform
r
What's going to matter here is the GPU time, not CPU time
âž• 1
The length of each command on the render thread doesn't include the GPU time (at least on mobile architectures)
s
Yes, you’re right, but it’s kind of a low-hanging fruit, at least. Technically, it would be better to use something like Android GPU Inspector, but it’s much more flaky and doesn’t work with many devices.
There’s also a tool from ARM for GPU command inspection. I forgot what it’s called, but it’s quite good as well.
r
You can see the total GPU time in perfetto, so you can do a/b comparisons. It just won't give you details
z
Oh this is interesting, thanks for the replies