Measure execution time with a closure
Measures the execution time with a closure.
def benchmark = { closure ->
start = System.currentTimeMillis()
closure.call()
now = System.currentTimeMillis()
now - start
}
def duration = benchmark {
(0..10000).inject(0) { sum, item ->
sum + item
}
}
println "execution took ${duration} ms"