C++ vs C# Performance – Part 1

I have so far never seen a performance test where C/C++ did not win an easy victory due to it’s nature, but I am very curious about what I see in front of me now. The failure I pointed out earlier is how .NET or Windows behave then you push it to it’s limits, but the plot above is still 10 x Oscilloscope level plots at 27 FPS on a 1980xx1080 screen. That is Heavy raster Graphics behaving with video quality update – it is amazing to watch and open some usage opportunities that interest me.

Most developers will agree that raster graphics like .NET Forms is not the way to develop heavy graphics applications these days, but it still have some good usage schenarios and I like to test boundaries for my own education. In this case I will spend a little time and do the exact same plot in Qt and C++/MFC to compare 1:1 + I have a few bits of code that I have written in C++ and converted to C# so they can be used for comparisons as well.

So will C/C++ win an easy performance victory yet again? I expect it will, but the answer is not given. C/C++ compiles into static code while languages like C# compiles into a virtual machine’s assembly code and run on top of an interpreter called a “Virtual Machine”. Java uses Java VM, while C# compiles to a format called “MSIL” and run on .NET. What you need to be aware of is that computers are not single cores anymore and these interpreters are getting smarter using various technologies. The VM’s might also have a better C/C++ library and better usage of multiple cores out of the Box and the interpreters on some of these VM’s do a JIT to native machine code.

I will state that you can always win a performance game using C/C++ if you are willing to spend the time, but the question is more and more what do you get straight out of the box? My expectations right now is that C# .NET 4.6.2 might very well outperform Qt and C++/MFC on 1:1 raster graphics, but it will still be far behind on algorithmic speed. In reality we will be comparing Qt, MFC’s and .NET’s implementations of C/C++ raster graphics libraries because guess what – .NET is still written in C/C++.

Stay tuned. 

Leave a Reply