Status Update
Comments
cc...@google.com <cc...@google.com> #2
Can you do this yourself by creating a custom TraceMetric that wraps a StartupTimingMetric, and does this query?
We can definitely make this easier though, maybe an API like:
metrics = listOf(StartupTimingMetric() - TraceSectionMetric("MyNetworkEvent", Mode.first))
Want to be careful that it's not unsafe, and captures only bits of the startup critical path. As a custom extension function though, could be useful.
ml...@google.com <ml...@google.com> #3
I think if devs would need to write a custom metric for this, it might be hard.
I see custom metrics as a general custom way of measuring things (like frame drops for example)?
But I think it's doable to have a wrapper around this and trace.
Edit: getResults
is internal, so I can't do simply have a wrapper like this (I haven't tried it).
private val startup = StartupTimingMetric()
private val trace = TraceSectionMetric(sectionName)
override fun getResult(
captureInfo: CaptureInfo,
traceSession: PerfettoTraceProcessor.Session
): List<Measurement> {
val startupResults = startup.getResult(captureInfo, traceSession)
val traceResults = startup.getResult(captureInfo, traceSession)
val startupMeasurement = startupResults
.firstOrNull { it.name == "timeToInitialDisplayMs" }
?.data?.first()
?: return emptyList()
val traceMeasurement = traceResults
.firstOrNull { it.name == "${sectionName}Ms" }
?.data?.first()
?: return emptyList()
return listOf(
Measurement(
name = "timeToInitialDisplayWithout${sectionName}Ms",
data = startupMeasurement - traceMeasurement,
)
)
}
cc...@google.com <cc...@google.com> #4
Use cases I'd like to cover with this:
- Modifying captured metrics, as in
#comment1 - Splitting frames based on contents, e.g. while scrolling, frames that show new content vs those that don't
- Deriving different metrics from frames, e.g. ratio of Janky frames
This overlaps a lot with explorations we'd like to do for LazyList/RecyclerView macrobenchmarks.
Initial proposal is to expose high level events (like startup, frames), so that these can be trivially modified into custom metrics, while still letting the app fully customize their behavior + assertions. This could be e.g. time from beginning of startup, to first frame containing certain slice, or intersect list of "bind" slices with list of frames.
Description
Let's assume I have a
StartupTimingMetric
and measure TTID/TTFD. As part of the startup, the app makes a network call, which needs to be there. This network call might be a source of variation in the results and generally may pollute the startup metrics.There might be some workarounds to remove it from startup and get the clean data like
You could also have a
TraceSectionMetric("the_network_call")
for the call to find how much time it actually took, which you'd be able to subtract from the TTID/TTFD and see how much time the app actually spent starting.My question: could such post processing be part of the benchmarks?
Let's say a
StartupTimingMetric
would have an optional parameter with a trace section and would automatically remove the timing. Similarly, aTraceSectionMetric
could subtract other trace section.This is an exploration if something like this would be possible or feasible.