in reply to Win32... CPU/RAM usage
Something like this?
See the { no_user_info => 1 } parmeter on the GetProcInfo() call. If you don't need user information, gathering it slows things down horribly. (Also, notice the lc inside the grep.)
#! perl -slw use strict; use warnings; use Win32::Process::Info; use Data::Dumper; my $pio_2 = Win32::Process::Info->new (); my @pids = $pio_2->ListPids (); my @proc_info; my %ofInterest = map { $_ => 1 } qw[ perl.exe cmd.exe textpad.exe ]; my @fields = qw[ Name WorkingSetSize UserModeTime KernelModeTime ]; printf "%-25s %-14s %-12s %-14s\n", @fields; for my $pid (@pids) { @proc_info = $pio_2->GetProcInfo( { no_user_info => 1 }, $pid); for my $info ( grep{ exists $ofInterest{ lc $_->{ Name } } } @proc_info ) { printf "%-25s %14d %12.6f %14.7f\n", @{ $info }{ @fields }; } } __END__ C:\test>junk4 Name WorkingSetSize UserModeTime KernelModeTime CMD.EXE 1605632 2.328125 5.5156250 CMD.EXE 36864 0.015625 0.4218750 TextPad.exe 6189056 215.453125 108.9843750 CMD.EXE 65536 0.015625 0.2812500 perl.exe 7122944 0.375000 0.2187500
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Win32... CPU/RAM usage
by mikejones (Scribe) on Jul 06, 2007 at 19:51 UTC | |
by BrowserUk (Patriarch) on Jul 06, 2007 at 21:34 UTC |