Package net.imglib2.util
Class StopWatch
- java.lang.Object
-
- net.imglib2.util.StopWatch
-
public class StopWatch extends java.lang.ObjectUtility class to measure time differences in nano-seconds, based onSystem.nanoTime(). It compensates glitches inSystem.nanoTime(), such that the stop time can never be earlier than the start time. (For example, see stackoverflow)
-
-
Constructor Summary
Constructors Modifier Constructor Description privateStopWatch()UsecreateStopped()orcreateAndStart()to create a StopWatch.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StopWatchcreateAndStart()Construct and start a newStopWatch.static StopWatchcreateStopped()Construct newStopWatch.longnanoTime()Get the total time the clock was running, in nano-seconds.private longsafeNanos()doubleseconds()Get the total time the clock was running in seconds.static java.lang.StringsecondsToString(double seconds)voidstart()Start the clock.voidstop()Stop the clock.java.lang.StringtoString()Get the total time the clock was running as string.
-
-
-
Constructor Detail
-
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 Detail
-
createStopped
public static StopWatch createStopped()
-
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
public java.lang.String toString()
Get the total time the clock was running as string. Note that the clock can be started and stopped multiple times, accumulating the time intervals it was running in between.- Overrides:
toStringin classjava.lang.Object
-
secondsToString
public static java.lang.String secondsToString(double seconds)
-
-