Are java.lang classes better served by the JVM?
Mark Roos
mroos at roos.com
Fri Sep 28 09:49:11 PDT 2012
>From Raffaello
are java.lang classes better served by the JVM than other classes?
Here's a small experiment.
I created a MyInteger class that exposes the very same
implementation
of Integer.numberOfTrailingZeros(int), copied verbatim.
We did similar micro benchmarks, using Hanoi as a test case, to see the
speed variations
the various types of integers would have. We tried int, long, Long and
our version of
a boxed long. One case where we saw a 3-5x difference was between boxed
and
primitive versions. This was expected.
The other case was when we compared our custom boxed long with the Java
Long.
We found the issue here was with the creation and collection of instances.
The use of
the integer cache made a huge difference. Once we did that out times
became very close.
So while there may be internal optimization by the JVM in the Hanoi case
it had a minor
effect.
regards
mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/mlvm-dev/attachments/20120928/1190bcfa/attachment.html
More information about the mlvm-dev
mailing list