src/linux_parser.cpp
// Read and return the number of active jiffies for a PID
Read and return the number of active jiffies for a PID
Read and return the number of active jiffies for a PID
long LinuxParser::ActiveJiffies(int pid) {
  long timeTotal;
  string line, time;
  vector<string> timeArr;
  std::ifstream stream(kProcDirectory + std::to_string(pid) + kStatFilename);
  if (stream.is_open()) {
    std::getline(stream, line);
    std::istringstream linestream(line);
    while(linestream >> time) {
      timeArr.push_back(time);
    }
  }
  timeTotal = std::stol(timeArr[13])
     + std::stol(timeArr[14])
     + std::stol(timeArr[15])
     + std::stol(timeArr[16]);
  return timeTotal / sysconf(_SC_CLK_TCK);
}
long LinuxParser :: ActiveJiffies ( int pid ) { long timeTotal ; string line , time ; vector < string > timeArr ; std :: ifstream stream ( kProcDirectory + std :: to_string ( pid ) + kStatFilename ) ; if ( stream . is_open ( ) ) { std :: getline ( stream , line ) ; std :: istringstream linestream ( line ) ; while ( linestream >> time ) { timeArr . push_back ( time ) ; } } timeTotal = std :: stol ( timeArr [ 13 ] ) + std :: stol ( timeArr [ 14 ] ) + std :: stol ( timeArr [ 15 ] ) + std :: stol ( timeArr [ 16 ] ) ; return timeTotal / sysconf ( _SC_CLK_TCK ) ; }
Read and return the number of active jiffies for a PID
Read and return the number of active jiffies for a PID