Skip to content

Instantly share code, notes, and snippets.

@maxpert maxpert/Stopwatch.kt
Created Mar 16, 2016

Embed
What would you like to do?
A really simple stopwatch for Kotlin
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
You can’t perform that action at this time.