benchmarkbug.groovy
来自「大名鼎鼎的java动态脚本语言。已经通过了sun的认证」· GROOVY 代码 · 共 30 行
GROOVY
30 行
/** * A little performance test * @version $Revision: 1.4 $ */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 }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?