Is there any way to measure the rendering time of ...
# compose
f
Is there any way to measure the rendering time of compose? I want to calculate the rendering time of the same Composable function on Android and iOS.
k
Copy code
@Composable
fun MeasureRenderingTime() {
    // Start measuring when the composable is first composed
    val startTime = remember { Instant.now() }

    LaunchedEffect(Unit) {
        // Perform your action and then measure the time
        val endTime = Instant.now()
        val duration = ChronoUnit.MILLIS.between(startTime, endTime)
        // Log the duration
        println("Rendering time: $duration ms")
    }

    // Content of the composable
    Column {
        Button(onClick = {}) {
            Text("Button 1")
        }
        Button(onClick = {}) {
            Text("Button 2")
        }
    }
}

@Preview
@Composable
fun PreviewMeasureRenderingTime() {
    MeasureRenderingTime()
}
👍 1