Finding CPU stats on Win?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I need to used perl to gather CPU counts and stats of each processor
(speed, RAM cache, Hyperthreaded, etc).

Anybody know of a way, or a script, to gather this information? ASPN
was of little help. Currently running ASPerl 5.8.3 on Win2k Systems.


Re: Finding CPU stats on Win? wrote:
Quoted text here. Click to load it

This can be accomplished with the use of Win32::OLE and
WMI. I've put together a few lines that give a simple

use strict;
use warnings;
use Win32::OLE qw(in);

my $wmi = Win32::OLE->GetObject(
              '\root\cimv2' );

my $procs = $wmi->ExecQuery('SELECT * FROM Win32_Processor');

foreach my $processor ( in($procs) ) {
   print "Processor ID ".$processor->.": $/";
   print "Manufacturer: ".$processor->.$/;
   print "Model Name: ".$processor->.$/;
   print "Processor Speed is ".$processor->." MHz$/";
   print "Level 2 Cache size is ".$processor->." KB$/";

(only tested under XP)

Which hardware classes to query and which attributes they
carry can be looked up on the Microsoft Developer Network
homepage at
[Attention: line break]">


Re: Finding CPU stats on Win?

Nice, now I just gotta find out if there's  a way to read if a CPU has
Hyperthreading enabled or not (or if it's possible).

I searched for Hyperthread on the MS Library site and came back with
zero results. Know where I might need to look to find this out?

Re: Finding CPU stats on Win?

guice666 wrote
Quoted text here. Click to load it

I'm not sure if there's a reasonably simple way at all to query
that information. I don't have a HT system here,
but maybe if you toy around with the different WMI classes
(Win32_Processor's SocketDesignation parameter, the
Win32_ComputerSystem and Win32_ComputerSystemProcessor
classes) you can find something. Maybe the cpucount tool
from intel could also be of some help for you, but if I recall
correctly it's just available as a binary. If not, you will most
probalby have to go the hard way, reading out cpuid using
some inlined C or assembler code and comparing the appropriate
bit value in EBX.

But now the whole thing is getting away from perl quite fast,
so I'm setting an X-Post and FollowUp to


Site Timeline