Hi:
I'm trying to measure the % CPU usage of a process but I get strange results. Currently I'm using sigar 1.6.3. The code I'm using is:
Sigar sigar=new Sigar();
ProcCpu pcpu = sigar.getProcCpu(sigar.getPid());
t0=pcpu.getTotal();
tot0=sigar.getCpu().getTotal();
DO SOME TASKS
pcpu = sigar.getProcCpu(sigar.getPid());
t1=pcpu.getTotal();
tot1=sigar.getCpu().getTotal();
float percent=(t1-t0)/(tot1-tot0)
When I print the result of t1-t0 I always get 0 when I execute it on Linux 64 bits but when I execute it on Mac and Windows I obtain correct results. Can someone help me with this?
If I use the getPecent() method I also obtain 0 values
Thanks
Message was edited by: jrds
I'm trying to measure the % CPU usage of a process but I get strange results. Currently I'm using sigar 1.6.3. The code I'm using is:
Sigar sigar=new Sigar();
ProcCpu pcpu = sigar.getProcCpu(sigar.getPid());
t0=pcpu.getTotal();
tot0=sigar.getCpu().getTotal();
DO SOME TASKS
pcpu = sigar.getProcCpu(sigar.getPid());
t1=pcpu.getTotal();
tot1=sigar.getCpu().getTotal();
float percent=(t1-t0)/(tot1-tot0)
When I print the result of t1-t0 I always get 0 when I execute it on Linux 64 bits but when I execute it on Mac and Windows I obtain correct results. Can someone help me with this?
If I use the getPecent() method I also obtain 0 values
Thanks
Message was edited by: jrds