libcommonc++  0.7
CPUStats Class Reference

System CPU utilization statistics. More...

#include <CPUStats.h++>

Inheritance diagram for CPUStats:
Collaboration diagram for CPUStats:

Public Member Functions

 CPUStats ()
 Construct a new CPUStats object. More...
 
 ~CPUStats ()
 Destructor. More...
 
float getSystem (int cpu=-1) const
 Get the percent of CPU time spent in privileged (kernel) mode. More...
 
float getUser (int cpu=-1) const
 Get the percent of CPU time spent in unprivileged (user) mode. More...
 
float getNice (int cpu=-1) const
 Get the percent of CPU time spent on low-priority tasks. More...
 
float getIdle (int cpu=-1) const
 Get the percent of CPU time spent on the idle task. More...
 
uint_t getCPUCount () const
 Get the number of CPUs in the system. More...
 
bool collect ()
 Collect (update) the stats represented by this object. More...
 
void reset ()
 Reset the stats object. More...
 

Detailed Description

System CPU utilization statistics.

Author
Mark Lindner

Constructor & Destructor Documentation

◆ CPUStats()

CPUStats ( )

Construct a new CPUStats object.

◆ ~CPUStats()

~CPUStats ( )

Destructor.

Member Function Documentation

◆ collect()

bool collect ( )
virtual

Collect (update) the stats represented by this object.

Returns
true if the stats were collected successfully, false otherwise.

Implements SystemStats.

◆ getCPUCount()

uint_t getCPUCount ( ) const
inline

Get the number of CPUs in the system.

◆ getIdle()

float getIdle ( int  cpu = -1) const

Get the percent of CPU time spent on the idle task.

Parameters
cpuThe CPU number or -1 for the average across all CPUs.
Exceptions
OutOfBoundsExceptionIf the value of cpu is invalid.

◆ getNice()

float getNice ( int  cpu = -1) const

Get the percent of CPU time spent on low-priority tasks.

Parameters
cpuThe CPU number or -1 for the average across all CPUs.
Exceptions
OutOfBoundsExceptionIf the value of cpu is invalid.

◆ getSystem()

float getSystem ( int  cpu = -1) const

Get the percent of CPU time spent in privileged (kernel) mode.

Parameters
cpuThe CPU number or -1 for the average across all CPUs.
Exceptions
OutOfBoundsExceptionIf the value of cpu is invalid.

◆ getUser()

float getUser ( int  cpu = -1) const

Get the percent of CPU time spent in unprivileged (user) mode.

Parameters
cpuThe CPU number or -1 for the average across all CPUs.
Exceptions
OutOfBoundsExceptionIf the value of cpu is invalid.

◆ reset()

void reset ( )
virtual

Reset the stats object.

Implements SystemStats.


The documentation for this class was generated from the following files: