today I want to show some interesting results from benchmarking Lycia. The most interesting isn't want it shows by the first look at the chart, I mean we all should know Java on Linux performs out Java on Windows. What was so impressive to me is: for some reason (maybe the internal design of Lycia) using reflection at generation of runtime parsers isn't much slower than to create them by using bytecode production.
Both systems run on latest Java 1.6.0_20 so both are using the latest HotSpot compiler. The next days I will retry the benchmark on some more JVMs and especially on some 1.5 versions to see if it is the new HotSpot or if it is the internal design of Lycia which makes that minimal difference between both generation strategies.
To explain what I was expecting:
For me it was totally clear that bytecode generation would be more expensive in at creation but must perform out the reflection at runtime what is obviously not the fact.
For bytecode generation Lycia creates a complete new class at runtime which is compiled and loaded like any other precompiled class. This means, after some time, the HotSpot compiler make the bytecode into native cpu instructions.
For reflection, by contrast, a proxy class is instanced and the parser method is called by introspection of itself every time.
So there are 4 possibilities why the result is so "wrong" for me:
* Im wrong with my expectations
* Lycia's internal design thwarts bytecode generation from performing
* The HotSpot compiler in newer Java versions can optimize reflection calls
* The benchmark is just wrong (for example cause of using a constant expression for being parsed)
I attach both, the results as PDF and the benchmark class for being reviewed. It would be fine if someone could give informations and optinions about the benchmarking. Microbenchmarks are always hard to do.
There are no related posts for this blog entry