Skip to content

Instantly share code, notes, and snippets.

@jwalgemoed
Last active September 14, 2018 15:43
Show Gist options
  • Save jwalgemoed/109081611a1dc4c0e5d11b185eae7a68 to your computer and use it in GitHub Desktop.
Save jwalgemoed/109081611a1dc4c0e5d11b185eae7a68 to your computer and use it in GitHub Desktop.
fun main(args: Array<String>) {
var assign: String
val time = measureTimeMillis {
assign = "Value Assigned"
}
println("$time ms. spent assigning: '$assign!!'")
}
private inline fun measureTimeMillis(block: () -> Unit): Long {
val start = System.currentTimeMillis()
block()
return System.currentTimeMillis() - start
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment