Public Member Functions | |
OneCpuStats (void) | |
Empty default ctor. | |
OneCpuStats (const std::string &line) | |
Parse line from the file. | |
OneCpuStats | operator- (const OneCpuStats &b) const |
Subtract corresponding values from two caches. | |
long long | Sum (void) const |
Sum values in this cache. | |
Data Fields | |
std::vector< long long > | stat_cache |
Data from file. | |
Static Public Attributes | |
static const size_t | CPU_IDLE_COLUMN = 3 |
Index of the column with "idle time". |
This stores all numbers for one processor that are in the /proc/stat file. Each cpu line looks like this:
cpu? USER NICE SYSTEM IDLE IOWAIT IRQ SOFTIRQ
where ? is index of the cpu (or space if line represents global stats) and all USER ... SOFTIRQ are times that given processor spent doing tasks associated with given column. Number of columns is different between different kernels, but first four field are supported always. All fields are in USER_HZ, which usually is 1/100th of a second (but may be different and I know of no sane way of determining that value). We are usually interested only in the fourth column which counts time spent in the idle thread, but we still need to consider other columns when calculating CPU usage.
lm::LoadMonitor::ProcessorStats::OneCpuStats::OneCpuStats | ( | void | ) | [inline] |
Empty default ctor.
lm::LoadMonitor::ProcessorStats::OneCpuStats::OneCpuStats | ( | const std::string & | line | ) |
Parse line from the file.
This will parse given string and extract all columns with numbers into the vector.
line | One line from the /proc/stat file which contains data about the CPU. |
LoadMonitor::ProcessorStats::OneCpuStats lm::LoadMonitor::ProcessorStats::OneCpuStats::operator- | ( | const OneCpuStats & | b | ) | const |
Subtract corresponding values from two caches.
Subtracts two caches. Works like n-dimensional vector subtraction.
b | Cache to subtract from this. |
long long lm::LoadMonitor::ProcessorStats::OneCpuStats::Sum | ( | void | ) | const |
Sum values in this cache.
Sums all values stored in this cache.
const size_t lm::LoadMonitor::ProcessorStats::OneCpuStats::CPU_IDLE_COLUMN = 3 [static] |
Index of the column with "idle time".
std::vector< long long > lm::LoadMonitor::ProcessorStats::OneCpuStats::stat_cache |
Data from file.