Skip to content

Instantly share code, notes, and snippets.

@lildata
Created June 19, 2015 12:59
Show Gist options
  • Save lildata/43d0ad640bbc1075f266 to your computer and use it in GitHub Desktop.
Save lildata/43d0ad640bbc1075f266 to your computer and use it in GitHub Desktop.
A very simple stopwatch
object Stopwatch {
def time[R](block: => R): R = {
val t0 = System.nanoTime()
val result = block // call-by-name
val t1 = System.nanoTime()
println("Elapsed time: " + (t1 - t0) + "ns")
result
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment