Strange when other people write benchmarks, Java is slower than C. When I write benchmark Java is comparable with ASM. Perhaps it’s just way how do you aproach this thing.
[quote]Original Source Code is from Christopher W. Cowell-Shah http://www.cowell-shah.com/research/benchmark/code and from http://dada.perl.it/shootout/ and Doug Bagley http://www.bagley.org/~doug/shootout . I took portions and whole parts from both and put them into a single file and did some changes + bugfixes.
[/quote]
Well he admits this. So all that current benchmarks were based on that old Doug code.
It’s funny if C++ is faster than Java by around 15/100, then that’s acidentaly the same value as is ASM faster than C++.
Such benchmarks could be more interesting if they wouldn’t use FileReader/Writer.
As to B question. This bechmark measured different things so it’s just partialy valid. Also he is unexperienced with Java, and possibly in C++ (I hate when I’d have to repair programs screwed by someone else). Actually if we would ignore sin/cos tests, Java was faster in four cases.
C++ has unprecise sin, Java uses more perfect way. So he compared two method with two different results. We could be nasty and say C++ method doesn’t have high enough precision so C++ failed this test. JET failed as well.
Remmember that old joke about Intel and Motorola? How much is…
On my computer trig math completed in (scaled towards his test) 6000 ms. True this is twice as much as C++, but it’s uninteresting for real game.
Interesting for real aplication is that correct double results of sin and cos are avilable.
0.990665 vs 0.9906646477361263
it might be interesting if typing sin() without Math or StrictMath would activate native instruction “where avilable” with possibility of as bad results as could be on Intel processors.