Created
March 16, 2016 04:16
-
-
Save maxpert/6ca20fe1a70ccf6ef3a5 to your computer and use it in GitHub Desktop.
A really simple stopwatch for Kotlin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Stopwatch { | |
inline fun elapse(callback: () -> Unit): Long { | |
var start = System.currentTimeMillis() | |
callback() | |
return System.currentTimeMillis() - start | |
} | |
inline fun elapseNano(callback: () -> Unit): Long { | |
var start = System.nanoTime() | |
callback() | |
return System.nanoTime() - start | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
now we have
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.system/
measureXYZ methods