-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add new and rearrange existing execution time measurements and log me…
…ssages #86
- Loading branch information
1 parent
55bbbb4
commit 5c79af4
Showing
27 changed files
with
469 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/** | ||
* StopWatch.java Copyright UCAR (c) 2018. University Corporation for Atmospheric Research (UCAR), | ||
* National Center for Atmospheric Research (NCAR), Research Applications Laboratory (RAL), P.O. Box | ||
* 3000, Boulder, Colorado, 80307-3000, USA.Copyright UCAR (c) 2018. | ||
*/ | ||
|
||
package edu.ucar.metviewer; | ||
|
||
/** | ||
* @author : tatiana $ | ||
* @version : 1.0 : 05/11/18 15:02 $ | ||
*/ | ||
public class StopWatch { | ||
|
||
private Long startTime; | ||
private Long stopTime; | ||
private Long duration; | ||
private Long totalDuration; | ||
|
||
public static void main(String args[]) throws Exception { | ||
StopWatch stopWatch = new StopWatch(); | ||
stopWatch.start(); | ||
|
||
for (int i = 0; i < 10000000; i++) { | ||
Object obj = new Object(); | ||
} | ||
stopWatch.stop(); | ||
System.out.println(stopWatch.getFormattedDuration()); | ||
|
||
stopWatch.start(); | ||
for (int i = 0; i < 10000000; i++) { | ||
Object obj = new Object(); | ||
} | ||
stopWatch.stop(); | ||
System.out.println(stopWatch.getFormattedDuration()); | ||
System.out.println(stopWatch.getFormattedTotalDuration()); | ||
} | ||
|
||
|
||
public void start() { | ||
startTime = System.nanoTime(); | ||
stopTime = null; | ||
|
||
duration = null; | ||
|
||
} | ||
|
||
public void stop() throws Exception { | ||
if (startTime == null) { | ||
throw new Exception("Start time was never set"); | ||
} | ||
stopTime = System.nanoTime(); | ||
duration = stopTime - startTime; | ||
if (totalDuration == null) { | ||
totalDuration = duration; | ||
} else { | ||
totalDuration = totalDuration + duration; | ||
} | ||
|
||
} | ||
|
||
public Long getTotalDuration() { | ||
return totalDuration; | ||
} | ||
|
||
public String getFormattedDuration() throws Exception { | ||
if (duration == null) { | ||
throw new Exception("Start or stop time was never set"); | ||
} | ||
return MVUtil.formatTimeSpan(duration / 1000000); | ||
} | ||
|
||
public String getFormattedTotalDuration() throws Exception { | ||
if (totalDuration == null) { | ||
throw new Exception("Start or stop time was never set"); | ||
} | ||
return MVUtil.formatTimeSpan(totalDuration / 1000000); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.