Re: WHy is C# so much slower than c++???

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



This makes the times 12.6 secs for C++ and 15-16 seconds for C#.
Much more reasonable.
I suspect there was an underflow/overflow situation and the C++ code
stopped executing.

Still C# is still ~ 20% slower than C++. Managed C++ too!

Hi,
enable the optimizer in your C# project settings. It is disabled by default.
Then the C++.NET and C# results should be nearly identical.
Native C++ will probably a bit faster dues to lower memory overhead.

For more accurate timing you should use the StopWatch class, and not include
the Console.WriteLine statements in your time measurements. That will give
you ms accuracy or better.

As far as switching to C# goes: from personal experience I can say that
application development times and debugging times are much shorted in C#
than in native C++ or even C++.NET.
YMMV.

--

Kind regards,
Bruno van Dooren
bruno_nos_pam_van_dooren@xxxxxxxxxxx
Remove only "_nos_pam"


.