| 118 | } |
| 119 | |
| 120 | void SystemStateInfo::ReadProcStatString(const string& stat_string) { |
| 121 | cpu_val_idx_ = 1 - cpu_val_idx_; |
| 122 | DCHECK(cpu_val_idx_ == 0 || cpu_val_idx_ == 1) << "cpu_val_idx_: " << cpu_val_idx_; |
| 123 | CpuValues& next_values = cpu_values_[cpu_val_idx_]; |
| 124 | |
| 125 | // Skip the first value ('cpu '); |
| 126 | StringPiece sp(stat_string); |
| 127 | DCHECK(sp.starts_with("cpu ")); |
| 128 | ReadIntArray(sp.substr(5), NUM_CPU_VALUES, &next_values); |
| 129 | } |
| 130 | |
| 131 | void SystemStateInfo::ComputeCpuRatios() { |
| 132 | const CpuValues& cur = cpu_values_[cpu_val_idx_]; |