Load Testing with Custom Performance Counters: Listing 1.
The DocumentManager class.
- By Benjamin Day
public class DocumentManager
private OperationPerformanceCounterManager m_PerfMonCountersForCreateDocument;
string categoryName = "My Application Name";
// Initialize an OperationPerformanceCounterManager;
// the Create Document operation
categoryName, "Create Document");
public int CreateDocument(string name)
// Get the start time
var startTicks = DateTime.Now.Ticks;
// Perform the operation
var documentId = DoCreateDocument(name);
// After the operation completes, record how long it took
DateTime.Now.Ticks - startTicks);
private int DoCreateDocument(string name)
// Do some work
Benjamin Day is a consultant and trainer specializing in software best practices using Microsoft tools. Ben’s main areas of emphasis include Team Foundation Server, Scrum, software testing, and software architecture. He is a Microsoft Visual Studio ALM MVP, a certified Scrum trainer via Scrum.org, and a speaker at conferences such as TechEd and Visual Studio Live! When not developing software, Ben’s been known to go running and sea kayaking in order to balance out his love of cheese, cured meats, and champagne. He can be contacted via www.benday.com.