IIS CPU usage Archives - Anuj Varma, Hands-On Technology Architect, Clean Air Activist https://www.anujvarma.com/tag/iis-cpu-usage/ Production Grade Technical Solutions | Data Encryption and Public Cloud Expert Tue, 05 Nov 2013 22:19:33 +0000 en-US hourly 1 https://wordpress.org/?v=7.0.2 https://www.anujvarma.com/wp-content/uploads/anujtech.png IIS CPU usage Archives - Anuj Varma, Hands-On Technology Architect, Clean Air Activist https://www.anujvarma.com/tag/iis-cpu-usage/ 32 32 How much CPU is my web app consuming? https://www.anujvarma.com/how-much-cpu-is-my-web-app-consuming/ https://www.anujvarma.com/how-much-cpu-is-my-web-app-consuming/#respond Tue, 05 Nov 2013 22:18:55 +0000 http://www.anujvarma.com/?p=1687 Introduction When running a load test, adding IIS specific performance counters is a good idea (this post details the most important IIS and ASP.NET counters). However, sometimes, all you want […]

The post How much CPU is my web app consuming? appeared first on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.

]]>
Introduction

When running a load test, adding IIS specific performance counters is a good idea (this post details the most important IIS and ASP.NET counters). However, sometimes, all you want is a quick look at the usage (CPU %) for just your web app, you can check it on your localhost. Cassini, Visual Studio’s built-in web server, runs under the process name – WebDev.WebServer40.exe. If you are running IIS 7 or above, the appropriate process name is w3wp.exe (so you would use w3wp as the instance name in the code below)

static void Main(string[] args)

        {

            // do not need the .exe in the instance name

            // For Cassini, instance name = WebDev.WebServer40

            // For IIS 7x , instance name = w3wp 

            PerformanceCounter myAppCpu =

                new PerformanceCounter(

                    "Process", "% Processor Time", "WebDev.WebServer40", true); 

 

            Console.WriteLine("Press any key to stop...\n");

            while (!Console.KeyAvailable)

            {

                double pct = myAppCpu.NextValue();

                Console.WriteLine("WEB APP CPU % = " + pct);

                Thread.Sleep(250);

            }

        }

This provides a quick console view of the processor usage – as you run your test.

Source Code Download

 

IIS CPU Usagedownload

The post How much CPU is my web app consuming? appeared first on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.

]]>
https://www.anujvarma.com/how-much-cpu-is-my-web-app-consuming/feed/ 0