Skip to content

Instantly share code, notes, and snippets.

@djcas9
Created September 28, 2010 13:25
Show Gist options
  • Save djcas9/600982 to your computer and use it in GitHub Desktop.
Save djcas9/600982 to your computer and use it in GitHub Desktop.
/* CPU STATS - at the end of output record */
#ifdef LINUX_SMP
/* First the number of CPUs */
fprintf(fh, "%d,", sfBaseStats->sfProcPidStats->iCPUs);
/* Next, stats for each CPU (a triple) */
for(iCtr = 0; iCtr < sfBaseStats->sfProcPidStats->iCPUs; iCtr++)
{
usr= sfBaseStats->sfProcPidStats->SysCPUs[iCtr].user;
sys= sfBaseStats->sfProcPidStats->SysCPUs[iCtr].sys;
idle= sfBaseStats->sfProcPidStats->SysCPUs[iCtr].idle;
fprintf(fh,"%.3f,%.3f,%.3f,",usr,sys,idle);
}
#else
usr=sfBaseStats->user_cpu_time;
sys=sfBaseStats->system_cpu_time;
idle=sfBaseStats->idle_cpu_time;
/* 1 CPU hardcoded */
fprintf(fh,"1,%.3f,%.3f,%.3f,",usr,sys,idle);
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment