Created
May 12, 2015 19:08
-
-
Save nelanka/b056a46164e1d197e700 to your computer and use it in GitHub Desktop.
Time a function in Scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def time[R](block: => R): R = { | |
val t0 = System.nanoTime() | |
val result = block | |
println("Elapsed time: " + (System.nanoTime - t0) + "ns") | |
result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment