( Index )
Month

Brief Information about the May '08 CSIG Meeting

Windows Performance Counters

C++ Version 7 and Visual Studio 2005, etc.

B. Arnold

Cpu History

Welcome to the CSIG, a Special Interest Group of the ACGNJ. The subject for this month is a discussion about the Windows Performance Counters which are provided inside the operating system. Yes, they're in there right now. Windows 2000, WinXP, and of course Windows Vista. A utility will be created using this concept for displaying the current activity of the CPU (Central Processing Unit) of the computer. It uses the latest C++ compiler in Microsoft's Visual Studio 2005. There are a number of ways to refer to this compiler and code. Here's what Wikipedia says:

The Common Language Infrastructure (CLI) is an open specification developed by Microsoft that describes the executable code and runtime environment that form the core of the Microsoft .NET Framework. The specification defines an environment that allows multiple high-level languages to be used on different computer platforms without being rewritten for specific architectures.

Microsoft .Net Framework 2.0
C++ 7.0
.Net 2.0
CLI
Common Language Infrastructure
Managed

The .net programming enviornment provides a special class within the System.Diagnostics namespace. This PerformanceCounter class allows access to the hundreds of performance counters that are contained in the operating system. (It also provides the ability to create new counters.) At the May meeting, we will explore this counter mechanism and demonstrate a program utility for displaying one particular counter, the Percentage of Processor Time. As shown in the above screen shot, this counter shows a display similar to part of the Task Manager.

And here is a list taken from the IDE: Representative Performance Counters List

Sample Code

    // Land here every second.
    private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
                 // Move all data points down 1 index position.
                 int i;
                 for (i=0; i<GRIDPOINTS-1; i++)
                     data[i] = data[i+1];
                 // Now put the latest data at the end.
                 data[i] = filter(performanceCounter1->NextValue());
                 this->Text = String::Format("{0} % CPU", data[i]);
                 pictureBox1->Invalidate();
             }


    private: System::Void pictureBox1_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) {
                 Pen ^mPen = gcnew Pen(System::Drawing::Color::LawnGreen, 5.0F);
                 mPen->SetLineCap(LineCap::Round, LineCap::Round, DashCap::Round);
                 Point P0 = Point(0,100);
                 Point P1 = Point(0,100);

                 for (int i=0; i<GRIDPOINTS; i++)
                 {
                     P0 = P1;
                     P1.X = i*GRIDSCALE;
                     P1.Y = GRIDHEIGHT - data[i];
                     e->Graphics->DrawLine(mPen, P0, P1);
                 }
             }

    private: int filter(float arg)  // build digital low pass filter
             {
                 sumOfTen = 0.9F * sumOfTen;
                 sumOfTen += 0.1F * arg;
                 return Math::Round(sumOfTen);
             }

"Random Access" questions start at 7:30 Tuesday night.

SOURCE CODE

Source Code Files

For help, email me at b a r n o l d @ i e e e . o r g
Back to C++ Main Page