From: hyperguy <sig...@hy...> - 2009-10-27 19:01:12
|
Just to answer my own question - though, it would be nice to get feedback from a guru to see if this is the "right" approach. Basically, I spawned a thread that created its own instance of a sigar object. Within the thread, it calls something like this: while (condition) { procTime = sigar.getProcCpu(pid); procMem = sigar.getProcMem(pid); long currentResident = procMem.getResident(); if (((int) currentResident) > pData.memorySize) { pData.memorySize = (int) currentResident; } long pageFaults = procMem.getPageFaults(); if (pageFaults > pData.pageFaults) { pData.pageFaults = pageFaults; } long minorFaults = procMem.getMinorFaults(); if (minorFaults > pData.minorFaults) { pData.minorFaults = minorFaults; } long majorFaults = procMem.getMajorFaults(); if (majorFaults > pData.majorFaults) { pData.majorFaults = majorFaults; } pData.cpuTime = procTime.getTotal(); pData.userTime = procTime.getUser(); pData.systemTime = procTime.getSys(); pData.exeTime = procTime.getLastTime() - procTime.getStartTime(); count++; sleep(100); } So over a given period of time, cpu and memory stats are collected. The pDate.exe time stat is weird. I would expect that the exeTime would be greater than the cpuTime number. HOWEVER, at least on windows and mac, the exeTime is SMALLER than cpuTime. Using windows api's (non-sigar), the opposite is true, i.e. exeTime > cpuTime using windows api's. Is there any reason to account for this difference? This discrepancy is giving me doubts on trusting the sigar produced numbers. In addition, on both windows and mac, the major faults and minor faults are always 0. According to the docs, pagefaults = majorfaults + minorfaults, but pagefaults is never 0. I'm using windows xp professional and mac os x snow leopard. |