Skip to content

DmitryNaumov/PerformanceCounters

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intro

Many times I was eager to add performance counter here and there... but it requires so much typing!!!

So I've decided to overcome it once and forever!

Break & Enter

Declare

[PerformanceCounterCategory("Sample Category", "Everything is so trivial", PerformanceCounterCategoryType.SingleInstance)]
public interface SampleCounters : IPerformanceCounterSet
{
	[PerformanceCounter("#Total Requests", "Total number of executed requests", PerformanceCounterType.NumberOfItems64)]
	IPerformanceCounter RequestsTotalCount { get; }

	[PerformanceCounter("#Executing Requests", "Number of currently executing requests", PerformanceCounterType.NumberOfItems32)]
	IPerformanceCounter RequestsExecutingCount { get; }

	[PerformanceCounter("Requests/sec", "Request rate", PerformanceCounterType.RateOfCountsPerSecond32)]
	IPerformanceCounter RequestRate { get; }

	[PerformanceCounter("Avg. Request Time", "Average request execution time", PerformanceCounterType.AverageTimer32)]
	IPerformanceCounter RequestAverageTime { get; }

	[PerformanceCounter("Avg. Request Time (base)", "Average request execution time", PerformanceCounterType.AverageBase)]
	IPerformanceCounter RequestAverageTimeBase { get; }
}

Use

var sampleCounters = PerformanceCounterFactory.GetCounters<SampleCounters>();
sampleCounters.RequestsTotalCount.Increment();

Showtime

Run sample application and open http://localhost:2707

Alt text

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published