netflix.ocelli.util.Stopwatch Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ocelli-core Show documentation
Show all versions of ocelli-core Show documentation
ocelli-core developed by Netflix
package netflix.ocelli.util;
import java.util.concurrent.TimeUnit;
public class Stopwatch {
public static Stopwatch createStarted() {
return new Stopwatch(System.nanoTime());
}
private Stopwatch(long startTime) {
this.startTime = startTime;
}
private long startTime;
private long endTime = -1;
public long elapsed(TimeUnit units) {
return units.convert(getRawElapsed(), TimeUnit.NANOSECONDS);
}
public long getRawElapsed() {
if (endTime == -1) {
return System.nanoTime() - startTime;
}
return endTime - startTime;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy