1 package benchmarks.common 2 3 import java.util.concurrent.* 4 doGeomDistrWorknull5public 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