My goal is to develop a mini-benchmark tool, so I can test the performance of a Web Api.
I want to create the performance counters programmatically using a simple console application. As part of my research, I created the main method below. This is just a simple test. So basically, I need HttpClient in order to forward an x-number of requests and then to view some metrics (i.e % Processor Time ) for this operation.
Is my logic correct?
static void Main(string args)
var client = new HttpClient();
var theCPUCounter = new PerformanceCounter("Process", "% Processor Time", Process.GetCurrentProcess().ProcessName);
var tasks = new int;
var counter = 0;
for (int i = 0; i< 1000; i++)
Parallel.ForEach(tasks, x =>
Console.WriteLine((theCPUCounter.NextValue() / 8));
I am aware that there are performance counters that make more sense, but for the time being, I just want to see if I understand it correctly.
If the above is correct then my plan is :
1)Create various throughput scenarios with concurrent requests using HttpClient and TPL(i.e send 1000 concurrent requests, but create different scenarios for every 100 in order to utilize various resources in the Web Api). As soon as I have those scenarios executed, then
2)I will be releasing the performance counters for measuring CPU and Memory.
That's the plan.
Can you please advise?