- So … How fast is Groovy?
- First Java …
public class Fact {
static final int N = 100000;
public static void main (String[] args) {
long start = System.currentTimeMillis();
for (int i=0; i < N; i++) {
fact(10);
}
long delta = System.currentTimeMillis() - start;
float t = ((float)delta) / N;
System.out.println("Java: "+(t*1000)+" MicroSeconds per call");
}
public static int fact(int n) {
int result = 1;
for (int i=2; i<=n; i++) {
result *= i;
}
return result;
}
}
Java: 0.39000002 MicroSeconds per call