View Full Version : Is CLR really 100 times slower than Win32
Al6200
April 16th, 2007, 09:46 PM
I've run 2 rather similar codes, one using unmanaged DirectX in C++, and another doing roughly the same thing using managed DirectX in C#. The one in C++ runs quite smoothly, with no hiccups or slowdowns whatsoever, however the one written in managed DirectX was only able to update the screen every second or two.
Since the C# code was written by me, and the C++ code was pulled from the internets, one could attribute the performance difference to my poor coding skills, yet that one would be a n00b. :?):?):?):?)...
...Or Santa Clause
:shifty:
Templarian
April 17th, 2007, 09:02 AM
Something tells me you may be doing something wrong (while managed has more overhead it shouldn't be significantly slower).
Paste your code for your version.
Al6200
April 17th, 2007, 05:45 PM
Really? Not significantly slower?
I've been considering that in my mound of code (its over 1000 lines), I accidentally am writing to the hard-drive in my main while loop, which certainly would account for a huge slow-down.
I've fixed a few things which have made it faster, but its still at least 20-30 times slower than unmanaged I reckon. I don't really mind using unmanaged, its just that C++ code is ugly in my opinion, and organizing large projects is more difficult.
TheColonial
April 17th, 2007, 10:20 PM
... I've fixed a few things which have made it faster, but its still at least 20-30 times slower than unmanaged I reckon....
You 'reckon? :D
My vote is that it's still your code :) Sorry if that sounds rude, but it's the truth. There have been many benchmarks run for C, C++, C# and Java, and there's a million and one comparisons of relative performance across the languages. From what I can see, none of them have shown a difference that great, which IMHO suggests that your design isn't optimal. If you have a read around the web and see the benchmarks you'll be surprised at how quick managed code is. Sure, it's always going to be slower than C++ in most cases, but it's a lot quicker than you think it is.
If you're sure it's not your code, then why not post it here and let us see for ourselves? :)
Cheers :nose:
OJ
hybrid101
April 18th, 2007, 06:47 AM
could it be a memory leak?
Templarian
April 18th, 2007, 09:22 AM
^Never used managed DX have your hybrid, you would have to try to make a memory leak for it to happen.
TheColonial
April 20th, 2007, 04:11 AM
As a rule of thumb, make sure you use the using (http://msdn2.microsoft.com/en-us/library/yh598w02(VS.80).aspx) statement around all your Disposable objects (where you can!).
If you're still not sure what's going on, post the code!
OJ
Al6200
April 20th, 2007, 09:28 AM
You mean like
n = new myClass();
using(n) {
n.something()
}
TheColonial
April 21st, 2007, 03:51 AM
using( MyClass mc = new MyClass() )
{
n.Something();
}
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.