Grab Win32::Process::Info and then try this. It lists name, pid, kernel and user mode cpu utilisations for all the processes in the system.
#! perl -slw
use strict;
use Win32::Process::Info;
my @info = Win32::Process::Info->new->GetProcInfo({no_user_info=>1});
printf "%20s : %5d : K:%10.3f U:%10.3f\n",
@{ $_ }{qw[Name ProcessId KernelModeTime UserModeTime ]}
for @info;
__END__
c:\test>pi
System Idle Process : 0 : K:192689.359 U: 0.000
System : 4 : K: 49.203 U: 0.000
...
TextPad.exe : 1112 : K: 43.328 U: 81.781
CMD.EXE : 1276 : K: 5.953 U: 3.422
CMD.EXE : 644 : K: 0.625 U: 0.219
CMD.EXE : 440 : K: 0.016 U: 0.031
TextPad.exe : 1524 : K: 6.141 U: 7.578
Opera.exe : 816 : K: 6.438 U: 9.516
perl.exe : 1508 : K: 0.000 U: 0.047
perl.exe : 1724 : K: 0.125 U: 0.188
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.