Skip to content

Instantly share code, notes, and snippets.

@atmb4u
Created December 29, 2016 20:24
Show Gist options
  • Save atmb4u/21481eefd2bc1367e0a26c76b2bf5b79 to your computer and use it in GitHub Desktop.
Save atmb4u/21481eefd2bc1367e0a26c76b2bf5b79 to your computer and use it in GitHub Desktop.
timeit for scala
// http://stackoverflow.com/questions/9160001/how-to-profile-methods-in-scala
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