collect over multiple stop/start

This commit is contained in:
Doug MacEachern 2005-03-09 18:36:28 +00:00
parent 2ad2c33bbf
commit 90ad5a74f2
1 changed files with 10 additions and 6 deletions

View File

@ -18,15 +18,19 @@ public class CpuTimer {
}
public CpuTimer(Sigar sigar) {
clear();
this.sigar = sigar;
}
public void start() {
this.startTime = System.currentTimeMillis();
public void clear() {
this.totalTime = 0;
this.cpuTotal = 0;
this.cpuUser = 0;
this.cpuSys = 0;
}
public void start() {
this.startTime = System.currentTimeMillis();
try {
this.cpu.gather(this.sigar, 0);
@ -38,15 +42,15 @@ public class CpuTimer {
public void stop() {
ThreadCpu diff = getDiff();
this.cpuTotal = diff.total;
this.cpuUser = diff.user;
this.cpuSys = diff.sys;
this.cpuTotal += diff.total;
this.cpuUser += diff.user;
this.cpuSys += diff.sys;
long stopTime = System.currentTimeMillis();
long time = stopTime - this.startTime;
this.totalTime = time;
this.totalTime += time;
}
public ThreadCpu getDiff() {