Click here to Skip to main content
13,346,664 members (67,834 online)
Click here to Skip to main content
Add your own
alternative version


26 bookmarked
Posted 29 Sep 2005

Performance Testing

, 29 Sep 2005
Rate this:
Please Sign up or sign in to vote.
Attach performance hooks to an assembly through a command line utility.


Last week I was tasked with improving the performance of our ASP.NET application. Not having much experience with performance testing and after reading a number of articles, I decided to start with some of the more popular tools that were available. I quickly discovered that for whatever reason, the metrics provided by these tools can be quite skewed and in some cases clearly incorrect.

The solution

What I really wanted to do was to create a disposable class and wrap the contents of each method in a using statement.

For example:

private void Form1_Load(object sender, System.EventArgs e)


private void Form1_Load(object sender, System.EventArgs e)
   using (PerformanceMonitor.PerformanceMonitor pm = 
               new PerformanceMonitor.PerformanceMonitor())

The constructor and destructor of the PerformanceMonitor class can output to a text file / event log / etc. The PerformanceMonitor can be customized as required.

I thought there’s got to be an easier way of adding in performance logging mechanism that runs better than the tools I had previously tried.

The result is a utility that disassembles an assembly using ILDASM, modifies the MSIL and reassembles the MSIL using ILASM. The end result is that each method has the using statement wrapped around it.

How to use

Before running the utility, the PerformanceMonitor class must be compiled and copied to the same directory as the assembly that is to be modified.

The utility and a sample PerformanceMonitor class are attached. The utility is a command line application with the usage: AttachPerformanceHooks.exe TestAssembly.dll.

This utility can be attached to any un-obfuscated, unsigned assembly. The results obtained so far using the PerformanceMonitor attached are not skewed and do not give incorrect results.

The PerformanceMonitor class will output to a text file in a directory supplied through the application setting: "PerformanceMonitor.LogDir".

Note: For larger assemblies (e.g. 90 MB MSIL) the utility can take a while to run.


So far I have been using this for a week and it has made my job much easier. I hope you will also find this utility useful.



This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Simon McEnlly
Web Developer
Australia Australia
No Biography provided

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.180111.1 | Last Updated 29 Sep 2005
Article Copyright 2005 by Simon McEnlly
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid