As far as I understand leJOS doesn't use JIT or HotSpot techniques. So the leJOS VM is a pure interpreter implementation of the JAVA VM. So far I don't have a NXT. But I'm curious to know how fast leJOS is compared to a native program, for example coded in C (here in contrast to NQC). In this forum I found something like this about performance:
- Code: Select all
200000 int add: 648 ms 308641 ops/sec
200000 int sub: 662 ms 302114 ops/sec
200000 int mul: 680 ms 294117 ops/sec
200000 int div: 941 ms 212539 ops/sec
200000 float add: 871 ms 229621 ops/sec
200000 float sub: 879 ms 227531 ops/sec
200000 float mul: 1028 ms 194552 ops/sec
200000 float div: 1868 ms 107066 ops/sec
200000 double add: 1723 ms 116076 ops/sec
200000 double sub: 1790 ms 111731 ops/sec
200000 double mul: 1678 ms 119189 ops/sec
200000 double div: 6090 ms 32840 ops/sec
What would be the results if programmed in C? Will C be 10, 50 or 100 times faster? Any idea?
Or, if I put my question into another simple program (which uses 'invokevirtual' only rarely) like:
- Code: Select all
public class Fibonacci32Bit {
static int fib(int n) {
if(n < 2)
return 1;
else
return fib(n-2) + fib(n-1);
}
public static void main(String[] args) {
long t0 = System.currentTimeMillis();
for(int i=0;i<=30;i++)
System.out.println("Fibonacci of "+i+" is "+fib(i)+" in "+(System.currentTimeMillis()-t0)+" ms");
}
}
What will be the results (the elapsed times) for leJOS and results for C on the NXT?
Thanks!
