Skip to content

Instantly share code, notes, and snippets.

@mariussoutier
mariussoutier / Time.scala
Created August 8, 2012 09:19
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
}