Performances with gcj

Benjamin de Dardel benjamin.dedardel@gmail.com
Tue Aug 12 19:10:00 GMT 2008


David Daney a écrit :
> Benjamin de Dardel wrote:
>   
>> Hi all,
>>
>> I had to release a program that executes an external process and gets 
>> its standard output.
>> I implemented a solution with threads and pipes to redirect inputs and 
>> outputs (cf PipeTest.java).
>>
>> I choose the 'find /' command to test it.
>> I'm very surprised about gcj performances which are 5x slowly than sun 
>> jvm.
>> In fact, I expected that my compiled program would be faster than all 
>> jvm.
>>
>> Do you have an idea about these differences ?
>> Is that the gnu classpath implementation which is quiet slow ?
>>
>>     
> I have not profiled it, but it is not too surprising.
>
> You could try buffering the process' input stream before sending it 
> through the InputStreamReader.
>
> I suspect that the slowdown is in the character set conversion.  You are 
> using the default converter.  You could also try something like US-ASCII 
> and see if that speeds things up.
>
> David Daney
>
>
>
>   
Hi David,

I rewrite the tests, using class BufferedInputStream.
Result seems to be more exact now :
- compilation is faster than interpretation,
- optimization increase performances.

Thanks for you help,
Benjamin

##### find / #####
# test1 : bash
$ time find /
real    2m6.541s
user    0m5.510s
sys     0m5.740s

# test2 : compilation with gcj
$ gcj --main=PipeTest -o test.bin PipeTest.java
$ time test.bin
real    8m3.392s
user    1m56.100s
sys     1m49.100s

# test3 : optimized compilation with gcj (level 2)
$ gcj -C PipeTest.java
$ gcj -O2 --main=PipeTest -o test.bin PipeTest.class Consumer.class 
Producer.class
real    7m18.718s
user    1m40.960s
sys     1m47.970s

# test4 : optimized compilation with gcj (level 3)
$ gcj -C PipeTest.java
$ gcj -O2 --main=PipeTest -o test.bin PipeTest.class Consumer.class 
Producer.class
real    6m55.568s
user    1m40.500s
sys     1m36.700s

# test5 : interpretation with gcj
$ gcj -C PipeTest.java
$ time gij PipeTest
real    9m59.789s
user    2m53.010s
sys     1m54.280s

# test6 : interpretation with java
$ javac PipeTest.java
$ time java PipeTest
real    11m45.988s
user    3m25.510s
sys     2m5.290s

##### compilers #####
$ gcj --version
gcj (GCC) 4.2.3 (Ubuntu 4.2.3-2ubuntu6)

$ javac -version
javac 1.6.0_03

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PipeTest.java
Type: text/x-java
Size: 2635 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java/attachments/20080812/e861d311/attachment.bin>


More information about the Java mailing list