Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.6-beta-1
-
Fix Version/s: 1.8-beta-4
-
Component/s: None
-
Labels:None
-
Environment:OS X Leopard
Groovy Version: 1.6-beta-1 JVM: 1.5.0_13
-
Testcase included:yes
-
Number of attachments :
Description
Consider the two attached fibonacci implementations. They both do things the same way. Both print out first the calculated value, then the time it took to calculate it. Under Java 1.5 and Groovy 1.6-beta-1, the groovy version is up to 90 times slower.
Here:fib ricardo$ javac fibj.java
Here:fib ricardo$ groovyc fib.groovy
Here:fib ricardo$ java fibj 30
1346269
16
Here:fib ricardo$ java fib 30
1346269
1241
Here:fib ricardo$ java fibj 40
165580141
1669
Here:fib ricardo$ java fib 40
165580141
150246
You can save another around 8-10% (on my machine) using:
def fib(i) { if (i == 0 || i == 1) return 1 return fib(i-1)+fib(i-2) } long millis = new Date().getTime() println fib(args[0]) println new Date().getTime() - millisbut there are plans in the works to save much more.