Skip to content

Instantly share code, notes, and snippets.

@lokkju
Created September 29, 2016 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lokkju/a8a4187cda502b346860bd66677964f3 to your computer and use it in GitHub Desktop.
Save lokkju/a8a4187cda502b346860bd66677964f3 to your computer and use it in GitHub Desktop.
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