The future is all virtual machine based-i mean to say every platform would become more and more managed. But at the cost of performance. C++ is still favorite of many because machine code is directly generated but not any MSIL or a bytecode. This makes the applications very fast to executed. But the managed environments provides developer a lot many comforts for which they are ready to give up performance to some extent. But with recent research in optimized JIT compilers, even Managed applications could be faster(not as much as native code). Well let me not drag the topic - i aint writing any book! I wanted to share some information which could be used to make your applications a bit faster(by applications i mean .NET apps)
There is also a tool called NGen that ships along with .NET SDK. Ngen.exe could be used to generate JIT compiled code and it saves the compiled code in GAC. Make a note that even this compiled code is managed, but when the application whose NGEN code is available in the GAC, JIT is no more functional at runtime- performance improves drastically. The documentation for NGen is really stupid and overly complex. Very soon i shall be working with Ngen and then i would post a simple tutorial on how to use it. Till then those interested can refer MSDN article here :
http://msdn.microsoft.com/msdnmag/issues/05/04/NGen/
Also there are more articles on Ngen and none of them are cool :( unfortunately they arent meant for you and me, they are for advanced geeks.
- Firstly, create as many less objects as possible - if your application runs for longer durations. Then also make sure to set the object reference to "nothing"/"null" when you are done while using it.
- Read FxCop rules and also PMD rules from pmd.sourceforge.net, though PMD is for Java the rules are well applicable to .NET since both of them rely about the same basics of runtime.
- Make sure that you save unnecessary loops, reducing loops always saves you CPU time. Also read this article on MSDN about performance of .NET applications. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/scalenetchapt13.asp
- One thing is that, avoid Boxing/UnBoxing as much as possible - the lesser the work for CLR for type-casting, better the performance.
There is also a tool called NGen that ships along with .NET SDK. Ngen.exe could be used to generate JIT compiled code and it saves the compiled code in GAC. Make a note that even this compiled code is managed, but when the application whose NGEN code is available in the GAC, JIT is no more functional at runtime- performance improves drastically. The documentation for NGen is really stupid and overly complex. Very soon i shall be working with Ngen and then i would post a simple tutorial on how to use it. Till then those interested can refer MSDN article here :
http://msdn.microsoft.com/msdnmag/issues/05/04/NGen/
Also there are more articles on Ngen and none of them are cool :( unfortunately they arent meant for you and me, they are for advanced geeks.
1 comment:
a aaahh,wow dude,Ngen documentation simplified by a hyderabadi sounds music to my ears!!wish u all da best regarding da same!!
Post a Comment