John Timney ( MVP ) said:
I think the average figure I saw being spoken about was to expect up to
20% slower. Not significant, and certainly with the increased
productivity something that can be worked on in budget if it was an
issue. Personally, I've not done a comparison to the levels you would
have done Richard.
I don't know where you got that figure from, but it is nowhere near the
figure I was told. Here are my comparisons for v2.0:
http://www.grimes.demon.co.uk/dotnet/man_unman.htm
For code that is not optimized or code that is optimized for space
managed C++ is *quicker* than unmanaged code (native code takes 138% the
time of that managed code takes). In the case of optimized for speed,
the managed code takes 4% more time, so it is only slightly slower than
managed code.
I performed these measurements two years ago for v1.1 and I got a figure
of 6% longer for speed optimised managed C++ over speed optimized native
C++. I showed this to the guy responsible for performance on the C++
team and his comment was 'that looks right'. No one mentioned a figure
of 20%, and as my measurements for a computationally intensive routine
show, a figure of 20% is far too high.
In the best case native code has a mere 4% advantage over managed code.
I know that some of the work I have been invoved in recently using
native C would have been unworkable in .NET as performance was the
driving factor.
If it involves direct memory manipulation (which is what C was designed
to do) then I agree, but only because .NET makes a point of trying to
prevent you from performing direct memory access. If it uses
manipulation of arrays of values then C is not likely to be
significantly faster than a managed language. Furthermore, your C#
development will take a lot less time than the C development, which is
the whole point of .NET - it is now being marketed as a RAD solution.
For me - as long as complete end to end performance was not the
driving factor I would choose c# over c/++ anytime.
I think you should take 'performance' out of your criteria because it
really is irrelevant in this discussion. .NET is NOT significantly
slower than native code. There are places where it is inappropriate (for
example device drivers and IMO services), but in terms of performance
you'll not notice a 4% difference.
Richard