31 std::ifstream cpuProcFile(path);
32 if (!cpuProcFile.is_open())
33 throw std::runtime_error(std::string(
"cpu info. unavailable"));
38 std::string searchString(
"cpu MHz");
39 while ((cpuProcFile.rdstate() & std::ios::failbit) == 0)
43 cpuProcFile.getline(readLine, 1024);
44 std::string readLineString(readLine);
45 if (readLineString.find(searchString) != std::string::npos)
48 size_t semicolonPosition = readLineString.find(
':', 0);
49 if (semicolonPosition == std::string::npos)
throw std::runtime_error(std::string(
"wrong format for cpu info file"));
50 std::string frequencyString(readLineString.substr(semicolonPosition + 1));
54 std::istringstream frequencySstream(frequencyString);
56 frequencySstream >> freqMHz;
67 unsigned long diff_low;
71 diff_low = (UINT_MAX - t1.
_low) + t0.
_low + 1;
82 const int max_col = 80;
85 os << std::string(max_col,
'-') << std::endl;
88 int fill = max_col - message.size() - 2;
89 int pre =
static_cast<int>(std::floor(fill / 2.0));
90 int post = fill - pre;
91 os << std::string(pre,
'-') <<
" ";
93 os << std::string(post,
'-') << std::endl;