How are you guys? I hope that everyone is OK.
Of course all of you know that VS.NET 2008 had released, and there is lots of guys downloaded it, and most of them until now are very happy with the nice IDE and the new features, I liked one thing about the new VS, it is the ability to debug in the .NET framework 3.5 , I have downloaded the new version of VS.NET (2008), I installed it and I start doing the thing that interest me which is debugging in the GREAT DOT NET FRAMEWORK, actually I was trying something so simple, I wanted to change the window title, the code was nothing as I think
this.Text = "New Title";
then I got into the code, and I got shocked, there is hell of processing happen to just set the window title, I didn't imagine that it is like that, I though that there is something wrong, so I go and write some code to test the performance
After I wrote the code I run the application in very normal way, and here is the result (I will explain what did that application do)
simply the application changes the window name 10000 times, and count the ticks using (GetTickCount)
it uses 2 techniques framework code "this.Text" and the Native Method which is using the API "SetWindowText"
and as you can see the snapshot, native is faster than the framework with about 70%,
the point here that the dot NET framework have lots of checks before doing the command, somehow it is necessary, in same time it is time consuming, as I think at certain point if you are really seeking for the performance you will get to the Native as your saver, I know that what I am talking about is not new, but many people are ignoring the performance issue, I am sure that .NET has many performance weakness, for many reasons, now I hope that you like this post and do some tests your self to see what I am talking about , I hope that the post was informative, thanks for your time
BR
Ahmed Essam

7 comments:
that is pretty very normal and expected, managed code is ofcourse is slower than native code
but there are advantages that is availble to the managed code and not for the native code and thats why the cost
I would not simply assume that .NET code is slower than Native just based on such one example. There will be cases where it is slower and there will be cases where it is faster. The best way to check is to measure, which is what you did in this case - great!
Also mind that you measured performance of WinForms framework vs. Win32 API. That is not the same as .NET (framework) vs. Native code. The WinForms does more, as you've noticed, so it takes more time.
Hi Maciek
The idea is there is lots of validation in the code when I have traced it, what I am talking about is some how dot NET framework need some kind of enhancement to control all of this validation, it is really to many checks, this checks aren't for free, it cost performance, dot NET is cool if you are talking about productivity, but in certain points it is the best way, in my work we do lots of C++ development, actually we do component to be consumed by dot NET, such thing is critical if your clients care about performance, but there is no doubt that dot NET framework is AMAMZING thing to save lots of time.
By the way, I perfrom the test with Win32 application and the result was 60% saved time more than the dot NET one.
Thanks for your time.
BR
Ahemd Essam
Alsalam alikom wa r7mat Allah wa barakatoh,
I believe using .NET is not only for safty/checks or whatever... it's also for portability, relying on Win32 APIs kills your portability ot other platforms (using mono most probably)
I agree with you that performance at some points will degrade if you used .NET rather than native calls... looking at the bright side and seeing the .NET Micro being installed on Ethernet cards... ur commercial processor may eventually run MSIL as it now runs assembly...
if your code will not really get benefit of those milliseconds difference, then I believe sticking to pure .NET code worth it.
Thanks,
Haytham Alaa
Peace be upon you
Welcome Haytham,
what you are talking about is totally true, if it is relying on Win32 APIs then it is done, this what COSMOS, portability issues, COSMOS is new FULLY managed Operating system, its idea is AMAZING, the guys did some engine called "IL2CPU" this converts the MSIL to Assembly code, which means that it is not good to have Inter Op things a round .NET code, because some how it will need to have runnable native code to complete the rest, in other hand there is Singularity it is not like COSMOS, in Singularity they admit that they have performances issues which means, the idea it self is not that good
over all, nothing will work better than the native MACHINE code, forget about IL(it means anything related to dot NET) or anything similar to it, the IDEA of VM like JAVA byte code and Microsoft Intermediate language all of that add performance over head on the machine, but I have to admit that something like COSMOS is GREAT idea, because it will convert the IL code in the end to MACHINE code, but it will also will have some issues, the issues will be in optimizing the application, but who knows may be it become better than anything,
but as you can see that COSMOS, has nothing to do with Portability, it may be CODE portable not binary portable which means at the end you are not under the umbrella of managed you are just got compiled under the managed umbrella then the umbrella is no more needed, because it is the machine code that will be used for life, you don't need to recompile or JIT or NGEN it is matter of binary code ready to run and that's it
sorry if the reply is not inharmonious, I really need to sleep :D, I hope that you get something from the reply
Thanks for your time
BR
Ahmed Essam
That was silly. You can look in .Net Framework source code and see what it is doing to set window text. And that's necessary.
Mr.Anonymous
First of all, what is the silly in your opinion? Second I think you should read enough to realize what we are talking about, Thanks for your time.
BR
Ahmed Essam
Post a Comment