Java trigonometry performance sucksJanuary 25, 2006 at 9:46 am | Posted in Programming | 4 Comments
Just did some benchmarking on creating swirlies both in Java and C#. The code is almost completely similar. I create a 200 x 200 pixel image and the results are somewhat shocking: in Java this takes 36.7 seconds while in C# only 10.2 seconds are needed. That’s almost 4 times as fast!
At first I thought I had made some trivial mistake in my code, since I’ve never seen such differences before. However when I looked at other benchmarks, for example this one it soon became clear that Java performance with trigonometry is bad, compared to most other programming languages. And swirlies happen to be full of trigonometric functions.
I hope this will be solved in the coming Mustang release but this is quite unlikely. in this blog it is explained that Java favors accuracy over speed. And one final remark: Mono was only 10 percent slower than .NET 2.0, which is not bad.