KL said:
I came across the following question. In .Net how would you compare
the performance of the same application written in VB.Net, VC++.net,
Native C++,VC#.net.
Would the performance be the same?
The first thing to consider is that the guys doing the JIT compiler came
from a background of writing optimized C++ compilers, so they knew a thing
or two about getting code to compile to optimized code.
I have performed performance tests between managed C++ and native C++ on a
computationally intensive routine (a Fast Fourier Transform). I used various
optimizer switches and I found that in most cases the managed C++ code ran
*faster* than the native C++ once I had discounted the time to perform the
JIT compilation. Bear in mind that Microsoft prohibits people from
publishing performance tests (there's a clause somewhere in the EULA).
Its easy to understand why managed C++ does so well - you can consider the
JIT compiler as effectively the back end of a C++ compiler. In effect, .NET
splits the compilation into two, with part of it occuring on the developer's
machine and the other part occuring in the JIT compilation. In the case of
native C++ the two parts occur on the developer's machine, which may be
different to the final machine. I don't know if JIT compilation takes into
account optimizations for the current free memory, or the specific CPU, but
clearly it could.
As to whether C++, C# or VB.NET is faster, well there's too many variables.
Security has an effect on performance, and note that C++ is not verifiable.
Richard