Jing Kang - 康 小靖 > Win32-Process-CpuUsage-0.02 > Win32::Process::CpuUsage

Download:
Win32-Process-CpuUsage-0.02.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.02   Source  

NAME ^

Win32::Process::CpuUsage - Perl extension for getting a Windows process's CPU usage

SYNOPSIS ^

  use Win32::Process::CpuUsage;

  ($pid, $interval, $counts) = (4800, 1000, 3);

  $rs = Win32::Process::CpuUsage::GetProcessCpuUsage($pid, $interval, $counts, $prcCPU, $sysCPU);

  $rs = Win32::Process::CpuUsage::GetPidCommandLine($pid, $str);

  $usage = Win32::Process::CpuUsage::GetSystemCpuUsage($interval);

DESCRIPTION ^

This module is designed to constantly monitor a Windows process's CPU usage and system CPU usage. And it has some merged methods from other 2 modules. You can find out more about how the CPU usage percentage computed from http://www.codeproject.com/KB/threads/Get_CPU_Usage.aspx.

METHODS ^

Win32::Process::CpuUsage::GetProcessCpuUsage($pid, $interval, $counts, $prcCPU, $sysCPU)

This method calculates the CPU usage based on process ID and time interval. The CPU usage means that within the specified time, for example 1000 milliseconds, how much CPU time is used by the process and system. The values of CPU usage are printed in DOS prompt for each calculation. The first value is the process CPU usage; the second one is system CPU usage. The values in last calculation are returned to variables, $prcCPU and $sysCPU.

If the method is called successfully, the return value is 0, otherwise it is -1.

Win32::Process::CpuUsage::GetPidCommandLine($pid, $str)

Same method in Win32::Process::CommandLine. Please see details in that module.

Win32::Process::CpuUsage::GetSystemCpuUsage($interval)

Same as method "getCpuUsage" in Win32::SystemInfo::CpuUsage. Please see details in that module.

SEE ALSO ^

Win32::Process::CommandLine

Win32::SystemInfo::CpuUsage

AUTHOR ^

Jing Kang <kxj@cpan.org>

syntax highlighting: