Microbenchmarking 3: C#

I added C# to the list of microbenchmarks I did recently.

C#
The C# test were made using Visual Studio 2003, using the default settings for Debug and Release versions. Compared to C++, there is some small performance penalty with the tight loop tests. Matrix multiply is even slower than in Java, ten times slower than in C++. The reason for this is probably the lack of fixed size array types in C#. The benchmark uses so called jagged arrays, the C# lingo for arrays of arrays. I also tried two-dimensional arrays, but they are even slower.
This experience confirmed the prejudices I had regarding C#: The language is superflous; between Java and C++ there is no gap this language fills. The syntax seems slighly more cumbersome than in Java, if you e.g. look at the initializers for jagged arrays. The .NET class library seems to be ok at first glance, e. g. DateTime is based on a 64 Bit value containing 100-nanosecond intervals that have elapsed since 12:00 A.M., January 1, 0001. The range will last for more than 50,000 years, the resolution can be used also for profiling and realtime computation purposes, even if I would have preferred at least one nanosecond resolution.

Windows:

Language LOOP CALL MAT4
Scheme MIT Rel. 7.7.1
(interp.)
730000 560000 8000
Ruby 1.8.0 2.7Mio. 1.4Mio. 12000
JavaScript 3.1 Mio. 1.8 Mio. 20000
Python 2.3 4.5 Mio. 2.1 Mio. 52000
Perl 5.8.0 8.5Mio. 1.4 Mio. 23000
Lua 8.7 Mio. 4.3 Mio. 23000
Scheme MIT Rel. 7.7.1
(compiled.)
3 Mio.
-60 Mio.
3.2 Mio.
-70 Mio.
67000
Spike-A 30 Mio. 6.5 Mio. n.a.
Spike-B 112 Mio. 19 Mio. 2.5 Mio.
Java -Xint.Sun 1.5.0_04-b05 87 Mio. 22 Mio. 160000
Java JITC Sun 1.5.0_04-b05 260 Mio. 52o Mio. 2.3 Mio
C++ Debug 270 Mio. 11 Mio.(!) 4.2 Mio
C# Debug 1400 Mio. 180 Mio. 1 Mio
C# Release 1400 Mio. 1200 Mio. 1.5 Mio
x86-Asm 2100 Mio. n.n. n.n.
C++ Release #inf #inf 14 Mio.

You can find the C# source here:

The other sources were already published here:

Kommentare sind geschlossen.