Skip to content

Commit 3357efc

Browse files
committed
use seconds
1 parent e917845 commit 3357efc

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

  • common-tools/clas-utils/src/main/java/org/jlab/utils/benchmark

common-tools/clas-utils/src/main/java/org/jlab/utils/benchmark/Benchmark.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ public static Benchmark getInstance(){
2323
return benchmarkInstance;
2424
}
2525

26-
public void printTimer(int interval){
26+
public void printTimer(int seconds){
2727
TimerTask timerTask = new TimerTask() {
2828
@Override
29-
public void run() { System.out.println(this); }
29+
public void run() { System.out.println(getInstance()); }
3030
};
3131
updateTimer = new Timer("Benchmark");
32-
updateTimer.scheduleAtFixedRate(timerTask, 0, interval);
32+
updateTimer.scheduleAtFixedRate(timerTask, 0, 1000*seconds);
3333
}
3434

3535
public void reset(){
@@ -95,4 +95,17 @@ public String toString(){
9595
}
9696
return s.toString();
9797
}
98+
99+
public static void main(String[] args){
100+
Benchmark b = getInstance();
101+
b.printTimer(10);
102+
int loop = 0;
103+
while(true){
104+
b.resume("COUNT");
105+
loop++;
106+
b.pause("COUNT");
107+
try { Thread.sleep(2000); }
108+
catch (InterruptedException ex) {}
109+
}
110+
}
98111
}

0 commit comments

Comments
 (0)