This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
RE: Different results of java and C verion of same program ?
- From: David BalaÅic <david dot balazic at hermes dot si>
- To: java at gcc dot gnu dot org
- Date: Wed, 08 Mar 2006 11:06:23 +0100
- Subject: RE: Different results of java and C verion of same program ?
I wrote:
> Hi!
>
> I use gcc 3.3.5 (debian 3.1).
> *
> I have written a program in jav*a and compiled it with gcj.
> Then I ported it to C and compiled with gcc.
>
> They give different results !
>
> Can this be some compiler error ?
> Computing accuracy related ?
It turned out, it was a bug in my C code (buffer overflow) :-(
The problem now is : The Java compiled version is "too" slow.
Here are the runtimes :
- Sun JIT : 800 ms
- C (optimised build) : 400 ms
- gcj compiled : 4000 ms
As you see, gcj is 10 times slower. Different -O options don't help.
-O values above 2 make it break (null "pointer" exception right after
start).
The main part of the program is a double loop, comparing each element of
a Vector
with all other elements of the Vector (except itself).
Any ideas for speedup ?
I already got about 20% speedup by changing this :
for(int i=0; i<myVector.size() ; i++)
for(int j=0; j<myVector.size() ; j++)
To this :
int vecSize = myVector.size();
for(int i=0; i<vecSize ; i++)
for(int j=0; j<vecSize ; j++)
Regards,
David