Skip to content

Instantly share code, notes, and snippets.

@toantran-ea
Created July 13, 2020 23:37
Show Gist options
  • Save toantran-ea/0790203f2827d2d75ffa9ca4d7871f24 to your computer and use it in GitHub Desktop.
Save toantran-ea/0790203f2827d2d75ffa9ca4d7871f24 to your computer and use it in GitHub Desktop.
measureNanoTime.kt
/**
* Executes the given [block] and returns elapsed time in nanoseconds.
*/
public inline fun measureNanoTime(block: () -> Unit): Long {
val start = System.nanoTime()
block()
return System.nanoTime() - start
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment