All Downloads are FREE. Search and download functionalities are using the official Maven repository.

kotlin.util.System.kt Maven / Gradle / Ivy

There is a newer version: 2.1.0-Beta1
Show newest version
package kotlin.util

/**
Executes current block and returns elapsed time in milliseconds
*/
public fun measureTimeMillis(block: () -> Unit) : Long {
    val start = System.currentTimeMillis()
    block()
    return System.currentTimeMillis() - start
}

/**
Executes current block and returns elapsed time in nanoseconds
*/
public fun measureTimeNano(block: () -> Unit) : Long {
    val start = System.nanoTime()
    block()
    return System.nanoTime() - start
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy