This is a mirror of official site: http://jasper-net.blogspot.com/

Tools and Techniques for .NET Code Profiling

| Sunday, July 10, 2011
The pithy epigram “premature optimization is the root of all evil” has been variously attributed over the years to Donald Knuth, William Wulf and C.A.R. Hoare. (It appears that Hoare originated the phrase, but Knuth gets credit for popularizing it. See bit.ly/fW1jWE for a summary of Knuth’s thoughts on the subject.)

So what does this mean to you, the intrepid .NET developer? Should you ignore performance and code away to your heart’s content? Is it best to follow the whims of IntelliSense and rely on ever-faster hardware to scale your apps?

Well, no.

An important part of testing is making sure your application not only executes without errors, but also executes efficiently and responsively. That’s where code-profiling tools and techniques come into play. These let you, as part of the build and testing process, evaluate your code for constructions—and outright errors—that are likely to cause problems. You get an automated heads-up that points you directly at the places in your app that need refactoring.

Profiling Basics

A good place to start learning about .NET profiling is the Code Project article by Paul Glavich, “Profiling the Performance of a .NET Application” (bit.ly/fpua6i). You’ll not only get some basics on .NET profiling, but Glavich also introduces you to the ANTS Profiler (which we’ll get to a bit later).

Another great starting point is Amirthalingam Prasanna’s blog post, “Profiling Your .NET Code” (bit.ly/dDXWsF). He starts out by listing 10 reasons why you should profile your code, then walks you through the process using the CLR Profiler (bit.ly/eSJyWd).

In Brian Long’s extensive walkthrough of the Microsoft .NET Framework profiling APIs, “.NET Internals: The Profiling API” (bit.ly/hNEDYP), you’ll learn about performance counters, the Performance Monitor and the relevant APIs. You’ll also see how to create your own simple profiling tools to illustrate how the APIs work.

The CLR now provides extensive profiling support, and David Broman shows you how to use it in his blog post, “Profilers, in-process side-by-side CLR instances, and a free test harness” (bit.ly/dYeRnQ). Make sure to read through the archives of Broman’s site—there’s a lot of great information there.

Profiling gets really important when you’re doing high-performance, highly scaled programming. If that’s up your alley, check out the “SC08: Windows HPC: Multi-Core Parallel Code Profiling in VS2010” webcast on Channel 9 (bit.ly/gyeKPi).

Don’t miss the Visual Studio Profiler Team Blog (blogs.msdn.com/b/profiler) for profiling tips, tricks and late-breaking announcements.

Read more: MSDN magazine
QR: hh288073.aspx

Posted via email from Jasper-net

0 comments: