How should I go about evaluating the performance or execution time of C++ with CLR versus native C++?

My personal bias is that I believe C++ with CLR to be slower since it has to run on a virtual machine. I will also admit that I have never really been a fan of Visual C++ due to the syntax that has been added, so I wanted to know how to evaluate the performance of the two approaches and determine which is provably faster instead of relying only on my biases.


I did some benchmarks in the past on my own, and my experience was that native C++ was around a factor 2 faster than C++/CLI for my typical business case, without any relevant change in code - your mileage will vary. For me, a factor 2 was almost always fully acceptable to stick to C++/CLI side, because interaction with the .NET framework and other .NET code was much more important for me than this performance gain.


Well, as always these kind of questions can't be answered with an absolute yes or no.

My experiences in general is that C++/CLI performs fast enough for me to work with it in desktop applications, C library wrappers or similar. However, if I needed to build a large hard real time system, I would not use it.

You need to look at what you need to use it for and if it is really performance critical, you should build a prototype - or model or whatever you want to call it - and benchmark. Do you have a lot of disc IO? Do you need a lot of varying memory allocation? Do you have any real time constraints?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.