Skip to content

Commit

Permalink
Fix composition tracing metric name
Browse files Browse the repository at this point in the history
  • Loading branch information
mlykotom committed Nov 24, 2023
1 parent b4469e5 commit 7559472
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
13 changes: 13 additions & 0 deletions MacrobenchmarkSample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ To get composition tracing when running a macrobenchmark, you also need to use `
You can check the `Scroll List With Composition Tracing` run configuration that is part of the project,
which runs the scroll compose list benchmark while also recording the information on composition.

It produces results like in the following table:
```
FrameTimingBenchmark_scrollComposeList
%EntryRow (%Count min 5.0, median 6.0, max 6.0
%EntryRow (%Ms min 10.2, median 11.8, max 16.2
EntryRowCustomTraceCount min 5.0, median 6.0, max 6.0
EntryRowCustomTraceMs min 10.0, median 11.7, max 16.1
frameDurationCpuMs P50 4.8, P90 6.8, P95 8.9, P99 15.3
frameOverrunMs P50 -9.2, P90 -1.9, P95 266.9, P99 310.9
Traces: Iteration 0 1 2 3 4 5 6 7 8 9
```

And from there you can also delve into the system trace, which shows information on composition:
![System trace with composition tracing](media/composition-tracing.png)

### Reporting Issues
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class ComposeActivity : ComponentActivity() {
}

@Composable
private fun EntryRow(entry: Entry, modifier: Modifier = Modifier) = trace("EntryRow") {
private fun EntryRow(entry: Entry, modifier: Modifier = Modifier) = trace("EntryRowCustomTrace") {
Card(modifier = modifier) {
Row(verticalAlignment = Alignment.CenterVertically) {
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ class FrameTimingBenchmark {
// Measure custom trace sections by name EntryRow (which is added to the EntryRow composable).
// Mode.Sum measure combined duration and also how many times it occurred in the trace.
// This way, you can estimate whether a composable recomposes more than it should.
TraceSectionMetric("EntryRow", TraceSectionMetric.Mode.Sum),
TraceSectionMetric("EntryRowCustomTrace", TraceSectionMetric.Mode.Sum),
// This trace section takes into account the SQL wildcard character %,
// which can find trace sections without knowing the full name.
// This way, you can measure composables produced by the composition tracing
// and measure how long they took and how many times they recomposed.
// WARNING: This metric only shows results when running with composition tracing, otherwise it won't be visible in the outputs.
TraceSectionMetric("%.EntryRow%", TraceSectionMetric.Mode.Sum),
TraceSectionMetric("%EntryRow (%", TraceSectionMetric.Mode.Sum),
),
// Try switching to different compilation modes to see the effect
// it has on frame timing metrics.
Expand Down

0 comments on commit 7559472

Please sign in to comment.