|
|
|
By Karen Kenworthy
Flash back, for A moment, to the good old days. Remember telling your parents that you failed your latest math test? Searching for an explanation, you probably told them something like: "What's the big deal? I'll never have to use statistics anyway."
Until now. With a little tutoring, you can use statistics to analyze your PC's performance. Moreover, utilities like WINDOWS Magazine's Wintune and operating systems such as Windows 95 can offer some data for fine-tuning your hardware, operating system and applications.
Win95 includes an optional utility on the CD-ROM version (but not the floppy) called System Monitor, which enables you to view statistics about your computer's performance. If you don't have System Monitor installed, load your Windows 95 CD and follow these steps. First, click on Start/Settings/Control Panel and then on Add/Remove Programs. Next, click on the Windows Setup tab. Now highlight Accessories, click on Details and scroll down the Components menu until you find System Monitor. Enable its check box and click on OK. It can also be downloaded from the Internet ( http://www.microsoft.com/kb/softlib/cdextras.htm). Once installed, System Monitor can be found on the Start menu at Programs/Accessories/System Tools/ System Monitor.
System Monitor displays a scrolling graph that charts recent changes in selected statistics. You can customize System Monitor's display by selecting Add Item or Remove Item from the Edit menu. The available statistics are grouped into six categories (File System, IPX/SPX-Compatible Protocol, Kernel, Memory Manager, Microsoft Network Client, and Microsoft Network Server).
Within these categories, you'll find a wealth of statistics. For example, the File System category includes "Bytes read/second" and "Bytes written/second." These tell you how heavily your hard disk is being used and how quickly it is responding. This category also tracks "dirty" data-program data that is waiting in cache to be written to your hard disk. If your computer suddenly lost power, the "dirty" data would be lost.
Another neat performance indicator is "Processor Usage (%)," which can be found in the Kernel category. This statistic shows how close your CPU is coming to its maximum workload. If your Processor Usage consistently hovers above 65 percent, or often reaches 100 percent, it may be time to consider a CPU upgrade. However, be aware that some programs always consume all available CPU time, regardless of a processor's clock speed. Typical offenders include older communications utilities and DOS programs that continually poll the serial port or keyboard.
Click Here to see a 3.76 KB bitmap image of artwork which goes with this article, entitled:
Stat Master
System Monitor is useful, but it does have limitations. For one thing, information is displayed only temporarily before it scrolls off the screen. Also, the program doesn't display all the information available. For example, Windows 95 counts how many times its swap file is read (Page-Ins) from the time of boot-up, but System Monitor only reports reads per second.
To compensate, I wrote a more flexible program called WinMag Swap Monitor. It works closely with Win95's Registry, and can be enhanced to monitor any statistics kept by Windows 95. Download it here.
Win95's Registry is chock full of statistical data. One entire section of the Registry (all entries under the key HKEY_DYN_DATA) stores dynamic or changing data in RAM. By reading the Registry, my Swap Monitor program can obtain that very data for examination.
Swap Monitor, like the WinMag Tattler (see the May Power Windows column.), uses the Windows API calls RegOpenKeyEx, RegQueryValueEx and RegCloseKey to open, read and close the Registry. Inside Swap Monitor shows the Visual Basic 4.0 Declare statements and constant definitions needed to use these functions. First, we call RegOpenKeyEx, passing it the Registry key (HKEY_DYN_DATA) and subkey (PerfStats\StatData) under which the statistics are stored. The parameter KEY_QUERY_VALUE tells Windows you plan to read data, while the parameter hkey provides Windows with a place to store a pointer to your requested Registry location.
Next, call RegQueryValueEx, passing it the hkey value received a moment ago. The second parameter tells Windows the Registry Data Name you wish to read. Swap file reads (Page-Ins) are stored in "VMM\cPageIns," while swap file writes are stored in "VMM\cPageOuts." Notice the embedded backslashes in these data names. This can be a bit confusing, since backslashes normally separate subkeys from each other and from data names.
Each of these Registry entries consists of a 32-bit unsigned integer, which Swap Monitor stores in a variable named lData. Once retrieved, the data can be analyzed in any way you see fit. With Swap Monitor, the raw data is used to compute interesting statistics such as Page Ins and Outs per second (see Stat Master ). A timer causes the program to update its display once per second. After you've retrieved all the statistics you need, call RegCloseKey to tell Windows you're done reading the Registry.
Swap Monitor can be enhanced to do more than merely display the number of swaps per second. For example, displaying the number of swap reads and writes over a short period-say, the past 10 secondsÑmight be useful for checking the current state of your PC.
To calculate swaps per second over a 10-second period, add an array of Page-In and Page-Out counters to the program. The number of entries in the array should match the number of seconds in your periodÑ10, in this case. Then, once a second, have the program shift the Page-In and Page-Out counts from array entry n to entry n+1 (for example, shift entry 1 to 2, 2 to 3, etc.). The last, or oldest, entry should be discarded. The latest Page-In and Page-Out counts should be stored in the now-empty first entries of each array. Finally, sum the entries and display them on screen.
A "rolling average" is almost as easy. Instead of storing the running count of Page-Ins and Page-Outs in each array entry, just store the number of swap file reads and writes that have occurred since the previous second. Total each array's entries as before, but divide each sum by the number of array entries before displaying the results.
Karen Kenworthy is the author of Visual Basic for Applications, Revealed! (Prima Publishing, 1994), a non-programmer's introduction to VBA. She is also a contributing editor to WINDOWS Magazine and the manager of WINDOWS Magazine Online on America Online and CompuServe. Karen Kenworthy's e-mail ID is: karenk@winmag.com
|
|
|