https://kotlinlang.org logo
Title
m

mersan

11/05/2018, 10:55 AM
trying this code
runBlocking {

      val timer = measureTimeMillis { delay(1000) }
      println("Delay Measure: $timer")

      val timer2 = measureTimeMillis { Thread.sleep(1000) }
      println("Thread Sleep Measure: $timer2")

    }
but the result was unexpected for me:
Delay Measure: 1064
Thread Sleep Measure: 1002
Is it something I should expect the
delay
in coroutine takes more time than the
Thread.sleep
?
g

gildor

11/05/2018, 12:10 PM
There is additional dispatching in case of coroutunes
Also such micro benchmarking without proper test harness has not so much sense
m

mersan

11/05/2018, 1:45 PM
make sense 👍