[Mono-list] Array benchmark

Sijmen Mulder Sijmen Mulder <sjmulder@gmail.com>
Sat, 9 Oct 2004 11:29:21 +0200


On a game development forum, someone asked what method of storing 2D
arrays is faster. On .NET, there are three possibilities:

1. [y*width+x]
2. [x,y]
3. [x][y]

I was wondering too, so I wrote a benchmarker. I attached the source
and the results (as pdf). The results are remarkable!

With all methods with all resolutions, Mono -is- slowest. Until..
maximum optimalization is used. Then the Mono results are about 5
times as good as with Microsoft.NET. Another weird thing is that
normally, method 1 is way faster, but when Mono is used with maximum
optimalization, method 2 is faster. And when the version with a
resolution of a power of two is ran, both method 2 and 3 are faster.
Just take a look at the pdf :)

Could someone explain this odd behaviour? And why the speed difference
between non-optimized and optimized mono is so big? And why such
optimalization is not used by default?

-- 

 'May the Lord bless you and protect you. May the Lord smile on you
and be gracious to you. May the Lord show you his favor and give you
his peace.'
 'De Heer zegent je, en Hij bewaart je. De Heer kijkt met liefde naar
je, en Hij is je genadig. De Heer bedenkt het goede voor je, en geeft
je vrede.'

Sijmen Mulder