src/linux_parser.cpp
float LinuxParser::CalculateCpuUtilization (int pid) {
    float cpuUsage = 0;
    //long  systemUptime = UpTime();
    float totalCpu = ActiveJiffies(pid)/sysconf(_SC_CLK_TCK);
    float startTimeSeconds = UpTime(pid) ;
    //float netCpu = systemUptime - startTimeSeconds ;
    if (startTimeSeconds == 0) {
        cpuUsage = 0 ;
    }
    else {
        cpuUsage = totalCpu / startTimeSeconds ;
    }
    return cpuUsage ;
}
// Calculate CPU Utilization of a process
Calculate CPU Utilization of a process
Calculate CPU Utilization of a process
float LinuxParser::CalculateCpuUtilization (int pid) {
    float cpuUsage = 0;
    float totalCpu = ActiveJiffies(pid)/sysconf(_SC_CLK_TCK);
    float startTimeSeconds = UpTime(pid) ;
    if (startTimeSeconds == 0) {
        cpuUsage = 0 ;
    }
    else {
        cpuUsage = totalCpu / startTimeSeconds ;
    }
    return cpuUsage ;
}
float LinuxParser :: CalculateCpuUtilization ( int pid ) { float cpuUsage = 0 ; float totalCpu = ActiveJiffies ( pid ) / sysconf ( _SC_CLK_TCK ) ; float startTimeSeconds = UpTime ( pid ) ; if ( startTimeSeconds == 0 ) { cpuUsage = 0 ; } else { cpuUsage = totalCpu / startTimeSeconds ; } return cpuUsage ; }
Calculate CPU Utilization of a process
Calculate CPU Utilization of a process
//long  systemUptime = UpTime(); //float netCpu = systemUptime - startTimeSeconds ;