first test

Andrew Haley aph@redhat.com
Thu Jul 15 09:34:00 GMT 2004


Alessandro Di Maria writes:
 > Hello
 > 
 > After some days of compiling, I finally could start a first test:
 > 
 > public class Loop {
 > 
 > public static void main(String[] args) {
 > long before = System.currentTimeMillis();
 > for (int i=0; i < 1000000; i++){
 > int a = 27 + 3 * i;
 > String b = String.valueOf(a) + "hello";
 > }
 > long after = System.currentTimeMillis();
 > System.out.println("time: " + (after-before));
 > }
 > 
 > }
 > 
 > running it on Mac OS X 10.3.4 1.33 GHz G4:
 > 
 > java Loop
 > time: 2269
 > 
 > gcj --main=Loop -o Loop Loop.java
 > ./Loop
 > time: 4369
 > 
 > ??? the app compiled with gcj is twice as much slow as the one running 
 > through the VM ???
 > Redoing the test doesn't change much.
This isn't a test of the compiler, because it spends almost of of its
time inside the library calls. It's really a test of the performance
of the different Java runtime libraries.
However, I get 3860 ms for the JIT compiler and 4613 ms for gcj. That
means that gcj's implementation of strings and/or memory allocation is
slightly slower.
I don't know why there is such a disparity in your case. It is
possible that on Mac OS X you have a fast implementation of Strings.
Andrew.


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /