Speed Impact experiment on GCJ
Mark Wielaard
mark@klomp.org
Wed Feb 15 09:41:00 GMT 2006
Hi Rui,
On Wed, 2006年02月15日 at 01:41 +0000, Rui Wang wrote:
> Having compiled the code with -O3 flag, it runs much faster compare to
> previous one. Thanks.
Great. Please do post the results so people can compare with the
unoptimized version. It is interesting to see how different ways to
compile a program impact the speed.
> However, I wonder why we need optimization to make native machine code
> running faster than Java bytecode? In my experiment, the code is no
> more complicated than a HelloWrold program. It has no features that
> will mess things up like dynamic class loading. Therefore, the
> translation from Java to native code should be straightforward,
> isn't ?
Without -O2 (or higher) the compiler tries to produce native code as
fast as possible without even looking for some simple tricks to get fast
code. It doesn't know this is just a very small program (you might link
it with hundreds of files later) and it tries to get you code as soon as
possible in the most naive way. If you tell it you want optimized code
(-O2) it actually tries to give that to you, but it might take longer to
generate it.
Cheers,
Mark
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://gcc.gnu.org/pipermail/java/attachments/20060215/2fc0ae33/attachment.sig>
More information about the Java
mailing list