Performance in .Net

G

Guest

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?
 
M

Morten Wennevik

Hi KL,

Everything .Net would be similar in performance. Native C++ will be
slightly faster but the downside is it would also be much more complex and
error prone to work with (including memory leaks).
 
M

Mr. Mountain

VC++ .Net should be able to generate the fastest code, as long as you are
using C++/CLI (i.e., the version with VS.NET 2005, which is available as a
beta now).
 
R

Richard Grimes [MVP]

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
 
A

Alex Vinokur

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?

See, for instance, comparative performance of various methods for various C++ compilers (including Unmanaged and Managed Microsoft
C++ 13.00):

1) Comparative performance of various methods of copying files in C and C++ (including Unmanaged | Managed Microsoft C++ 13.00) at
http://groups-beta.google.com/group/comp.lang.c++/msg/f97708039daa8d6e
http://comments.gmane.org/gmane.comp.lang.c++.perfometer/38

2) Comparative performance of computing very large Fibonacci numbers at
http://comments.gmane.org/gmane.comp.lang.c++.perfometer/37
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top