Skip to content

Instantly share code, notes, and snippets.

@mariussoutier
Created August 8, 2012 09:19
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariussoutier/3293709 to your computer and use it in GitHub Desktop.
Save mariussoutier/3293709 to your computer and use it in GitHub Desktop.
Executes a given block of code and prints the elapsed time
def time[T](block: => T): T = {
val start = System.currentTimeMillis
val res = block
val totalTime = System.currentTimeMillis - start
println("Elapsed time: %1d ms".format(totalTime))
res
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment