Performance comparison

I fell over some posts arguing whether C++.NET is faster than C#. The arguments looked like religion so here is a real world comparison. For the benchmark engine I calculated the first 300 decimals of PI. It contains integer and floating point math and some string allocation/manipulation. I ran each test twice on my laptop and noted the second timer reading. Running time for release builds (no debugger attached):

  • Native C++: 1,22 sec.
  • Native C++ w/profiled optimization: 0,97 sec.
  • C++.NET: 1,02 sec.
  • C#: 1,22 sec. You can download the VS2005 test solution and try for yourself. (please contact me if you want this). Conclusion: The C++ .NET compiler generated code was 16% faster that the C# code. Only with profiled optimization the native C++ compiler performed equal to the managed C++ code!
Google
m@kli.dk @klinkby RSS feed  GitHub