my crude benchmark results

John Gabriele john3g@bestweb.net
Tue Jul 13 14:30:00 GMT 2004


On Jul 13, 2004, at 4:57 AM, Andrew Haley wrote:
> John Gabriele writes:
>> [snip]
>> Ok,.. heaven forgive me for the cycles I am about to burn...
>>>> Time taken to run:
>>>> in C:
>> 8.5 seconds
>>>> Java via Apple's JVM:
>> 22.2 seconds
>>>> Java via GCJ:
>> 25.5 seconds
>>>> [snip]
> gcj has its own math library that is very accurate but doesn't use the
> FPU's builtins. Turn that off with -ffast-math.
>> $ gcc main.c -O3 -lm -ffast-math
> $ time ./a.out
> Size = 50000
> Sum = 50000.000000
> 2.81user 0.01system 0:02.83elapsed 99%CPU

Ahhh... Thanks for the tips.
for main.c, no change.
>> $ gcj Main.java --main=Main -O3 -ffast-math
> $ time ./a.out
> Size = 50000
> Sum = 50000.0
> 3.53user 0.03system 0:04.19elapsed 84%CPU

> Java is slighty slower, probably because of bounds checks and
> synchronization.
>> Trying without bounds checks, to be a more accurate comparison with C:
>> $ gcj Main.java --main=Main -O3 -save-temps -ffast-math 
> -fno-bounds-check
> $ LD_LIBRARY_PATH=/usr/local/lib time ./a.out
> Size = 50000
> Sum = 50000.0
> 3.42user 0.03system 0:03.48elapsed 98%CPU
>> 21% slower. I can live with that.
>> Andrew.
>
Ok, using GCJ, AOT compiled, summary of my results:
no -O3: 25.5 seconds
with -O3: 24.2 seconds ( 5.1% improvement)
with -O3 and -ffast-math: 23.2 seconds ( 9.0% improvement)
also no-bounds-check: 22.2 seconds (12.9% improvement)
> ... this reminds me that we should try to get bounds check elimination
> into gcj before 3.5.

Oooh, a compile-time option to skip bounds-checking? Sweet.
James Damour wrote:
> P.S. Looking at the numbers, I think that Mr. Gabriel didn't use GCJ to
> "ahead of time" compile the java code.

I created my gcj-aot compiled most-optimized binary like so:
gcj Main.java --main=Main -O3 -save-temps -ffast-math -fno-bounds-check 
-o jfastest.out
and I've never even used gij.
Recall, I'm on a Mac here -- a PPC G3 -- so GCJ may optimize 
differently here
than on an Athlon. Also, Apple's JVM may be very different from Sun's 
(or
Blackdown's) JVM.
> P.P.S Mr. Gabriel, when you post your code where others can read it,
> kindly include *some* sort of license. Otherwise no one can legally
> display your code due to copyright limitations.

Thanks for the heads-up. I figured a trivial one-pager like that didn't
require any sort of license. In fact, it's pretty sad that this would 
even
come up over that teency bit of code (no offense to you -- you're just
pointing it out).
Oh -- and call me "John"!
:)



More information about the Java mailing list

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