Chapter 7: Profiling and Performance Counters

Overview

In the last chapter, we examined some of things you can do in your code to improve performance. In this chapter, we're going to continue along the same theme, but the focus in this chapter will be on the facilities that are available to assist in monitoring the performance of a managed application - in other words, identifying what particular factors might be causing an application to not perform well, so that you know which parts of the code to concentrate on when you are trying to improve its performance. Along the way we will cover some of the tools that are available for profiling and the underlying APIs. We'll also acquire some necessary background information, in particular including the principles behind how Windows manages memory.

The topics we will cover are:

  • Virtual memory management - I will explain how Windows manages virtual memory, and shares out the available RAM between the running processes. We will also explore the performance implications of this, and how to use the Task Manager to monitor the memory an application is consuming.

  • Performance Counters and PerfMon - I will cover both what performance counters are and how to access them programmatically from managed code as well as how to implement your own counters. We'll also look at the PerfMon tool that provides a rich user interface for monitoring any chosen performance counters on your system.

  • Profiling - I will examine the principles behind how commercial profilers work, using the Compuware profiler as an example to illustrate the information you can extract from a profiler. I'll also have a look at the allocation profiler, which can be used to obtain detailed information about the operation of the garbage collector, and show you how to implement your own code to monitor performance of other applications with high resolution.

Performance monitoring is one area in which it's well worth a look round the Web for utilities that you can use - there are countless third-party tools and utilities available that provide convenient user interfaces from which to monitor the performance and resource usage of applications. Much of this software is freeware, although for the most sophisticated profilers you will have to pay. Because of the number and variety of third-party tools available, it would be pointless trying to examine the use of any one of them in detail here. So instead, in this chapter we will mostly work with the main utilities that are provided by Microsoft - including the Task Manager and PerfMon - and use these to illustrate the basic principles behind performance monitoring. This should give you the background you need in order to assess the usefulness of some of the more sophisticated tools on the Internet. I would mention, though, that good places to start looking for performance monitoring utilities are http://www.sysinternals.com and http://www.gotdotnet.com.



Advanced  .NET Programming
Advanced .NET Programming
ISBN: 1861006292
EAN: 2147483647
Year: 2002
Pages: 124

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net