-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
val aggregator: FrameMetricsAggregator = FrameMetricsAggregator()
private var totalFrames = 0L
private var slowFrames = 0L
private var frozenFrames = 0L
override fun onStart() {
super.onStart()
this.lifecycleScope.launch(Dispatchers.Default) {
aggregator.add(this@MainActivity)
}
}
override fun onStop() {
super.onStop()
this.lifecycleScope.launch(Dispatchers.Default) {
val data = aggregator.metrics ?: return@launch
totalFrames = 0L
slowFrames = 0L
frozenFrames = 0L
data[FrameMetricsAggregator.TOTAL_INDEX].let { distributions ->
for (i in 0 until distributions.size()) {
val duration = distributions.keyAt(i)
val frameCount = distributions.valueAt(i)
totalFrames += frameCount
if (duration > 16)
slowFrames += frameCount
if (duration > 700)
frozenFrames += frameCount
}
}
aggregator.reset()
println("totalFrames: $totalFrames, slowFrames: $slowFrames, frozenFrames: $frozenFrames")
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels