After reading the bad trig scores, I tried to create a little class for faster math using look-up tables and floats (currently only sin, cos, tan). And I tried to benchmark them in different ways: Using the client and server, using -Xcomp and without.
The results in ms:
Server with -Xcomp:
TOTAL: 35501
Server without -Xcomp
TOTAL: 19258
Client with -Xcomp:
TOTAL: 22102
Client without -Xcomp:
TOTAL: 20350
I found these results very surprising indeed.
The results are a mix between java.lang.Math and my own FMath class. Interestingly, java.lang.Math executes faster on the client than on the server JVM here but my FMath class is faster on the server.
Now before you’ll all tell me “It’s a microbenchmark and you have to know what you’re measuring”, you’re probably right although I don’t rule out I’m dealing with 1 or more defficiencies, especially in the server.
So the real question here is: What am I measuring? Is there a way to know at all, without knowing the intimite dirty secrets of hotspot?
I mean if there isn’t, microbenchmarking is absolutely useless if you’re not a hotspot developer (which is probably old news). Which is too bad, because microbenchmarking can IMHO be very useful to measure your own code.
Even macro benchmarks seem hard to draw any reasonable conclusions from then…
(I’ll post the code in a minute)
Erik