Skip to content

Commit 9dffa45

Browse files
committed
Add RenderingMetrics aggregation to the library
1 parent 02f49b9 commit 9dffa45

File tree

4 files changed

+59
-18
lines changed

4 files changed

+59
-18
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.booking.perfsuite.rendering
2+
3+
/**
4+
* Class aggregating raw frame metrics into more high level representation suitable for
5+
* reporting and simpler to analyze
6+
*/
7+
public data class RenderingMetrics(
8+
9+
/**
10+
* Total amount of frames rendered during the screen session
11+
*/
12+
val totalFrames: Long,
13+
14+
/**
15+
* Amount of frames that take more that 16ms to render (considered as "slow")
16+
*/
17+
val slowFrames: Long,
18+
19+
/**
20+
* Amount of frames that take more that 700ms to render (considered as "frozen")
21+
*/
22+
val frozenFrames: Long,
23+
24+
/**
25+
* Amount of "good" frames that potentially could be rendered, but were "dropped" due to
26+
* rendering performance issues.
27+
*
28+
* For instance if we target 60fps, the "good" frame would be any frame rendered for less than
29+
* 16ms. But when we see "slow" frame that take 48ms to render, it spend the same time to render
30+
* as 3 "good" frames would spend. That means that due to performance issue the app has rendered
31+
* 1 frame, but 2 potentially good frames were dropped
32+
*/
33+
val droppedFrames: Long,
34+
35+
/**
36+
* Total time of freezing the UI due to rendering of the slow frames per screen session.
37+
* This metric accumulates all freeze durations during the screen session
38+
*/
39+
val totalFreezeTimeMs: Long = 0,
40+
41+
/**
42+
* Total time spent by user on current screen. Helpful as a supporting metrics, since sometimes
43+
* increase in Total Freeze Time might be caused by longer interactions with the screen
44+
*/
45+
val foregroundTimeMs: Long? = null
46+
)
47+

sampleApp/src/main/java/com/booking/perfsuite/app/monitoring/RenderingMetricsMapper.kt renamed to perfsuite/src/main/java/com/booking/perfsuite/rendering/RenderingMetricsMapper.kt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
package com.booking.perfsuite.app.monitoring
1+
package com.booking.perfsuite.rendering
22

33
import android.util.SparseIntArray
44
import androidx.core.app.FrameMetricsAggregator
55
import androidx.core.util.forEach
66
import androidx.core.util.isEmpty
77

8-
internal object RenderingMetricsMapper {
8+
public object RenderingMetricsMapper {
99

10-
fun toRenderingMetrics(
10+
/**
11+
* Aggregates raw frames data collected by [ActivityFrameMetricsTracker] into
12+
* [RenderingMetrics] data class, which is more suitable for reporting & metric analysis
13+
*/
14+
public fun toRenderingMetrics(
1115
metrics: Array<SparseIntArray>?,
1216
foregroundTime: Long?
1317
): RenderingMetrics? {
@@ -37,10 +41,10 @@ internal object RenderingMetricsMapper {
3741
}
3842

3943
return RenderingMetrics(
40-
total = total,
41-
slow = slow,
42-
frozen = frozen,
43-
dropped = dropped,
44+
totalFrames = total,
45+
slowFrames = slow,
46+
frozenFrames = frozen,
47+
droppedFrames = dropped,
4448
totalFreezeTimeMs = totalFreezeTime,
4549
foregroundTimeMs = foregroundTime
4650
)

sampleApp/src/main/java/com/booking/perfsuite/app/monitoring/ActivityFrameMetricsListener.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.app.Activity
44
import android.util.Log
55
import android.util.SparseIntArray
66
import com.booking.perfsuite.rendering.ActivityFrameMetricsTracker
7+
import com.booking.perfsuite.rendering.RenderingMetricsMapper
78

89
internal object ActivityFrameMetricsListener : ActivityFrameMetricsTracker.Listener {
910

sampleApp/src/main/java/com/booking/perfsuite/app/monitoring/RenderingMetrics.kt

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)