xref: /aosp_15_r20/external/kotlinx.coroutines/benchmarks/src/main/kotlin/benchmarks/common/BenchmarkUtils.kt (revision 7a7160fed73afa6648ef8aa100d4a336fe921d9a)
1 package benchmarks.common
2 
3 import java.util.concurrent.*
4 
doGeomDistrWorknull5 public fun doGeomDistrWork(work: Int) {
6     // We use geometric distribution here. We also checked on macbook pro 13" (2017) that the resulting work times
7     // are distributed geometrically, see https://github.com/Kotlin/kotlinx.coroutines/pull/1464#discussion_r355705325
8     val p = 1.0 / work
9     val r = ThreadLocalRandom.current()
10     while (true) {
11         if (r.nextDouble() < p) break
12     }
13 }
14