Duration and Time Measurement API

Kotlin 1.3.50

import kotlin.time.*

@UseExperimental(ExperimentalTime::class)
fun main() { 
  val (value, duration) = measureTimedValue { 
    Thread.sleep(100)
    42
  }
  // 42
  println(number)
  // e.g. 103 ms
  println(duration)
}

Back Home Next