src/linux_parser.cpp
// Todo: Read and return the number of active jiffies for the system
Read and return the number of active jiffies for the system
Read and return the number of active jiffies for the system
long LinuxParser::ActiveJiffies() { 
    string filepath = kProcDirectory + kStatFilename;
    std::ifstream file = GetStream(filepath);
    string key = "cpu";
    long sys_active_jiffies;
    string line;
    while(std::getline(file, line)) {
        if(line.compare(0, key.size(), key) == 0) {
            std::istringstream buf(line);
            std::istream_iterator<string> beg(buf), end;
            std::vector<string> values(beg, end);
            sys_active_jiffies = stol(values[2]) - stol(values[3]);
            break;
        }
    }
    file.close();
    return sys_active_jiffies;
}
long LinuxParser :: ActiveJiffies ( ) { string filepath = kProcDirectory + kStatFilename ; std :: ifstream file = GetStream ( filepath ) ; string key = " " ; long sys_active_jiffies ; string line ; while ( std :: getline ( file , line ) ) { if ( line . compare ( 0 , key . size ( ) , key ) == 0 ) { std :: istringstream buf ( line ) ; std :: istream_iterator < string > beg ( buf ) , end ; std :: vector < string > values ( beg , end ) ; sys_active_jiffies = stol ( values [ 2 ] ) - stol ( values [ 3 ] ) ; break ; } } file . close ( ) ; return sys_active_jiffies ; }
Todo: Read and return the number of active jiffies for the system
Todo : Read and return the number of active jiffies for the system