This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]