File tree Expand file tree Collapse file tree
common-tools/clas-utils/src/main/java/org/jlab/utils/benchmark Expand file tree Collapse file tree Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments