[NO ISSUE][HYR] Use System.nanotime for StopWatch
Change-Id: Ic64f1b938c26161f5fb482af5ee1da6121f49643
Reviewed-on: https://asterix-gerrit.ics.uci.edu/3339
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Ian Maxon <imaxon@uci.edu>
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/StopWatch.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/StopWatch.java
index e752cb3..a1a39cb 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/StopWatch.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/StopWatch.java
@@ -19,32 +19,27 @@
package org.apache.hyracks.api.util;
+import java.util.concurrent.TimeUnit;
+
public class StopWatch {
private long startTime = 0;
- private long stopTime = 0;
private long elapsedTime = 0;
public void start() {
elapsedTime = 0;
- startTime = System.currentTimeMillis();
+ startTime = System.nanoTime();
}
public void stop() {
- stopTime = System.currentTimeMillis();
- elapsedTime += stopTime - startTime;
+ elapsedTime += System.nanoTime() - startTime;
}
public void resume() {
- startTime = System.currentTimeMillis();
+ startTime = System.nanoTime();
}
- //elaspsed time in milliseconds
- public long getElapsedTime() {
- return elapsedTime;
+ public long elapsed(TimeUnit unit) {
+ return unit.convert(elapsedTime, TimeUnit.NANOSECONDS);
}
- //elaspsed time in seconds
- public long getElapsedTimeSecs() {
- return elapsedTime / 1000;
- }
}
\ No newline at end of file