|
Groovy example source code file (BenchmarkBug.groovy)
The Groovy BenchmarkBug.groovy source code
package groovy.bugs
/**
* A little performance test
* @version $Revision: 4996 $
*/
class BenchmarkBug extends GroovyTestCase {
void testPerformance() {
def start = System.currentTimeMillis()
def total = 0
def size = 10000
for (i in 0..size) {
total = total + callSomeMethod("hello", total)
}
def end = System.currentTimeMillis()
def time = end - start
println "Performed ${size} iterations in ${time / 1000} seconds which is ${time / size} ms per iteration"
// TODO: parser bug
// assert total == size * 10 + 10
assert total == 100010
}
def callSomeMethod(text, total) {
return 10
}
}
Other Groovy examples (source code examples)Here is a short list of links related to this Groovy BenchmarkBug.groovy source code file: |
Other websites by Alvin Alexander:
Life/living in Alaska (OneMansAlaska.com)
How I Sold My Business (HowISoldMyBusiness.com)
Copyright 1998-2011 Alvin Alexander, devdaily.com
All Rights Reserved.