Skip to content

Commit

Permalink
update: remove benchmark from test
Browse files Browse the repository at this point in the history
  • Loading branch information
muedsa committed Jan 23, 2024
1 parent 6b5013b commit 59b9791
Showing 1 changed file with 42 additions and 3 deletions.
45 changes: 42 additions & 3 deletions src/test/kotlin/com/muedsa/snapshot/benchmark/LogoBenchmark.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ package com.muedsa.snapshot.benchmark
import com.muedsa.snapshot.LogoCreator.Companion.logoContent
import com.muedsa.snapshot.SnapshotImage
import com.muedsa.snapshot.drawWidget
import kotlin.test.Test
import com.muedsa.snapshot.rendering.box.BoxConstraints
import com.muedsa.snapshot.widget.ProxyWidget


class LogoBenchmark {

@Test
fun benchmark() {
//@Test
fun image_benchmark() {
println("\n\nimage_benchmark")
System.gc()
val count = 10000
val startTime = System.currentTimeMillis()
for (i in 0..count) {
Expand All @@ -19,9 +22,45 @@ class LogoBenchmark {
}
val totalTime = System.currentTimeMillis() - startTime
val info = "Count: $count\nToto milliseconds: $totalTime\nAverage milliseconds: ${totalTime.toFloat() / count}"
println(info)
drawWidget("benchmark/logo", debugInfo = info) {
logoContent()
}
}

//@Test
fun renderTree_benchmark() {
println("\n\nrenderTree_benchmark")
System.gc()
val widget = ProxyWidget().apply {
logoContent()
}
val count = 1000000
val startTime = System.currentTimeMillis()
for (i in 0..count) {
widget.createRenderBox()
}
val totalTime = System.currentTimeMillis() - startTime
val info = "Count: $count\nToto milliseconds: $totalTime\nAverage milliseconds: ${totalTime.toFloat() / count}"
println(info)
}

//@Test
fun layout_benchmark() {
println("\n\nlayout_benchmark")
System.gc()
val widget = ProxyWidget().apply {
logoContent()
}
val renderRoot = widget.createRenderBox()
val count = 1000000
val startTime = System.currentTimeMillis()
for (i in 0..count) {
renderRoot.layout(BoxConstraints())
}
val totalTime = System.currentTimeMillis() - startTime
val info = "Count: $count\nToto milliseconds: $totalTime\nAverage milliseconds: ${totalTime.toFloat() / count}"
println(info)
}

}

0 comments on commit 59b9791

Please sign in to comment.