25 std::ifstream file_stat(
"/proc/stat");
29 const std::string str_tot(
"tot");
30 const std::string str_cpu(
"cpu");
31 const std::size_t len_str_cpu = str_cpu.size();
33 while (std::getline(file_stat, line)) {
35 if (!line.compare(0, len_str_cpu, str_cpu)) {
36 std::istringstream ss(line);
46 if (entry.
cpu.size() > len_str_cpu) {
47 entry.
cpu.erase(0, len_str_cpu);
48 entry.
cpu =
"core_" + entry.
cpu;
size_t times[kNumCpuStates]
void ReadStatsCPU()
parse /proc/stats.
std::vector< CPUData > entries_