Hi, how can I effectively measure the complete Jetpack Compose rendering time? I use the function below, but it is not working, since the function call completed before the rendering of the UI is completed.
Copy code
@Composable
override fun Content() {
val elapsedTime= measureTimeMillis {
MyDeepHierarchyJetpackComposeDrawing()
}
Log.d("Tracking", "Time used $elapsedTime")
}
Thanks!
w
Will Shelor
11/18/2021, 7:56 AM
I had this same problem a while back; a global layout listener gave a pretty good approximation of an endpoint. Profiling also gave a good picture of where things fit into the overall flow, though it impacted the timing of things pretty significantly.
r
romainguy
11/18/2021, 8:06 AM
systrace/perfetto will give you good timings in various parts of the system with very little overhead
romainguy
11/18/2021, 8:06 AM
It's definitely the better way to measure things like frame time
s
Sergey Y.
11/18/2021, 8:44 AM
I'm using Macrobenchmark library for that task.
It produces nice reports and raw Perfetto traces.