In software engineering, our knowledge is limited to what we can test via cause and effect. If we cannot measure the effect of something, it's hard to really know about it. This is one reason why people know relatively less about security and performance than coding "standard" features - it's hard to reliably measure them. However, help is on the way. There exists a free tool, the CLR Profiler, that lets you measure resources in managed code. Resource consumption is linked to performance, so this gives you a tangible way to diagnose some performance-related problems in your .Net App.
Version 2.0 has a great 100 page tutorial. There are other links out there too, such as:
- http://www.c-sharpcorner.com/Code/2004/Aug/CLRProfiler.asp
- http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/highperfmanagedapps.asp
I find this useful to see measurable differences in code snippets. The tutorial shows the difference for using StringBuilder to concatenate strings, but that's just the beginning. For example, the code snippet below opens a file 100 times. If I don't close the reader, I can see the affect of this in the CLR Profiler's "Histogram by Age for Live Objects" chart. In my case, normally the number of objects (less than 34kB) living less than .5 sec was 34KB. If I don't close the reader, it's 800KB.
|
This is a great tool that can be useful for diagnosing memory (and therefore performance) bottlenecks.
Thế giới trò chơi : www.gameonlineviet.com
ReplyDeleteKênh sức khỏe cho bé : www.tapchitonghop.com