Skip to content

Instantly share code, notes, and snippets.

@maxpert
Created March 16, 2016 04:16
Show Gist options
  • Save maxpert/6ca20fe1a70ccf6ef3a5 to your computer and use it in GitHub Desktop.
Save maxpert/6ca20fe1a70ccf6ef3a5 to your computer and use it in GitHub Desktop.
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
}
}
@sk1418
Copy link

sk1418 commented Aug 20, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment