![]() |
Unmanaged Code slower than Managed Code!
Hi Experts,
I'm trying to get into unmanaged DLLs and implementing them into C#-programs. The reason is simply to enhance the performance of a algorithm. So, getting into the basics I tried to test the speed by creating a for-loop, which counts up to a high value and returns a boolean parameter. Strangley the for-loop in the C#-Form runs faster, than the loop inside the dll (round 10% faster, I'd say). Here's the code: Code: DLL Code:
// DLL_Test_1.cpp : Definiert den Einstiegspunkt für die DLL-Anwendung.Code:
using System;Thanks for your help. Frankie-T |
Re: Unmanaged Code slower than Managed Code!
This is very much a possibility and I would not disagree but the speed is not only determined for running the for loop.
First why you get unexpected results as per your requirements is better use of memory and cache by the managed code. The speed of the program should be done from the time loader starts loading the program into memory to exit of the program and there you would see the difference. C# programs I have seen load faster second time than first time and so now you can safely assume why. |
Re: Unmanaged Code slower than Managed Code!
Hi,
thats disapointing. See, my problem is, that I have to fill a buffer with an image. It's huge (about 2000x5000px) and therefor it takes a while to fill the buffer. My idea was to bring the filling of the buffer into unmanaged code. Any idea how I could realize that? Frankie-T |
Re: Unmanaged Code slower than Managed Code!
Unless compelled try avoiding mixture of managed and un-managed code.
If you have some well tested un-managed code use it but do not try to develop both of them as switching can kill many things and specially time. |
| All times are GMT +5.5. The time now is 16:24. |