4579c9826f
fa500f453dAlex Tkachman Today 19:47725bebc23fAlex Tkachman Today 19:36
20 lines
447 B
Kotlin
20 lines
447 B
Kotlin
package std.util
|
|
|
|
/**
|
|
Executes current block and returns elapsed time in milliseconds
|
|
*/
|
|
fun measureTimeMillis(block: () -> Unit) : Long {
|
|
val start = System.currentTimeMillis()
|
|
block()
|
|
return System.currentTimeMillis() - start
|
|
}
|
|
|
|
/**
|
|
Executes current block and returns elapsed time in milliseconds
|
|
*/
|
|
fun measureTimeNano(block: () -> Unit) : Long {
|
|
val start = System.nanoTime()
|
|
block()
|
|
return System.nanoTime() - start
|
|
}
|