Class StopWatch
java.lang.Object
net.imglib2.util.StopWatch
Utility class to measure time differences in nano-seconds, based on
System.nanoTime(). It compensates glitches in
System.nanoTime(), such that the stop time can never be earlier than
the start time. (For example, see
stackoverflow)-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateUsecreateStopped()orcreateAndStart()to create a StopWatch. -
Method Summary
Modifier and TypeMethodDescriptionstatic StopWatchConstruct and start a newStopWatch.static StopWatchConstruct newStopWatch.longnanoTime()Get the total time the clock was running, in nano-seconds.private longdoubleseconds()Get the total time the clock was running in seconds.static StringsecondsToString(double seconds) voidstart()Start the clock.voidstop()Stop the clock.toString()Get the total time the clock was running as string.
-
Field Details
-
time
private long time -
total
private long total -
started
private long started -
running
private boolean running -
format
-
-
Constructor Details
-
StopWatch
private StopWatch()UsecreateStopped()orcreateAndStart()to create a StopWatch. This constructor will also create a StopWatch, just likecreateStopped(), but the more expressively named factory methods are preferred.
-
-
Method Details
-
createStopped
-
createAndStart
-
safeNanos
private long safeNanos() -
start
public void start()Start the clock. -
stop
public void stop()Stop the clock. -
nanoTime
public long nanoTime()Get the total time the clock was running, in nano-seconds. Note that the clock can be started and stopped multiple times, accumulating the time intervals it was running in between.- Returns:
- the total time the clock was running, in nano-seconds.
-
seconds
public double seconds()Get the total time the clock was running in seconds. Note that the clock can be started and stopped multiple times, accumulating the time intervals it was running in between. -
toString
-
secondsToString
-