This article is the continuation of previous one. So far you learned how to create and use performance counters in your application. In this section, I’ll show you how to control them through configuration.
Cinchoo framework generates meta data configuration file for all the performance counters you created in your application. This file will be created automatically in the application configuration folder. The file name will be [appExeName].perf.meta.
If you application executable name is HelloWorld.exe, this meta data file will be created in the name of HelloWorld.perf.meta. This is the default behavior.
This file name can be overridden. Please visit Framework Configuration Parameters section on how to achieve it.
For the samples from the previous sections, the meta data file will be created as below
<?xml version="1.0" encoding="utf-8"?> <configuration> <PerformanceCounterCategory name="Random Single Instance Test"> <PerformanceCounter name="Random Rate" turnOn="true" /> <PerformanceCounter name="Random Average" turnOn="true" /> </PerformanceCounterCategory> <PerformanceCounterCategory name="Random Multiple Instance Test"> <PerformanceCounter name="Random Value" instanceName="Standard" turnOn="true" /> <PerformanceCounter name="Random Value" instanceName="Inverted" turnOn="true" /> </PerformanceCounterCategory> </configuration>
A PerformanceCounterCategory section will be created for corresponding performance counter category. A PerformanceCounter element will be created for each performance counter in the category.
At present, turnOn is the only fact used by the framework to enable or disable the counter. You can touch this attribute any time (run-time as well), application pick up the changes and act accordingly.
If turnOn is true, the performance counter will be enabled. Otherwise it is disabled. This feature helps you to control the performance counter in the production environment as Performance Counters will affect your application performance.