-
Notifications
You must be signed in to change notification settings - Fork 3
Usage
ikopylov edited this page Dec 25, 2014
·
13 revisions
- Write class for every category you need. You class should be inherited from one of 3 library category class:
public class TestEmptyCategory: EmptyCategoryWrapper
{
public TestEmptyCategory() : base("Empty", "desc") { }
}
public class TestSingleInstanceCategory: SingleInstanceCategoryWrapper
{
public TestSingleInstanceCategory() : base("Single", "desc") { }
}
public class TestInstance: InstanceInMultiInstanceCategoryWrapper
{
}
public class TestMultiInstanceCategory : MultiInstanceCategoryWrapper<TestInstance>
{
public TestMultiInstanceCategory () : base("Multi", "desc") { }
}
- Define counters as properties inside your categories and mark them with 'Counter' attribute:
public class TestSingleInstanceCategory: SingleInstanceCategoryWrapper
{
public TestSingleInstanceCategory() : base("Single", "desc") { }
[Counter("TestElapsedTimeCounter")]
public ElapsedTimeCounter Elapsed { get; private set; }
[Counter("NumberOfItemsCounter")]
public NumberOfItemsCounter Count { get; private set; }
[Counter("TestOperationsPerSecondCounter")]
public OperationsPerSecondCounter OperationPerSec { get; private set; }
[Counter("TestAverageCountCounter")]
public AverageCountCounter Avg { get; private set; }
[Counter("TestAverageTimeCounter")]
public AverageTimeCounter AvgTime { get; private set; }
[Counter("TestMomentTimeCounter")]
public MomentTimeCounter MomentTime { get; private set; }
}
public class TestInstance: InstanceInMultiInstanceCategoryWrapper
{
[Counter("Count")]
public NumberOfItemsCounter Count { get; private set; }
}
-
If you need, you can write the singleton counters container:
-
Create on application start-up the CounterFactory or load it from App.config:
-
Initialize you categories:
-
Call InitAll on your factory:
-
Use counters:
-
Dispose counters factory when application is about to close: