|
Groovy example source code file (BenchmarkBug.groovy)
The Groovy BenchmarkBug.groovy source codepackage 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: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.