Package com.stripe.util
Class Stopwatch
java.lang.Object
com.stripe.util.Stopwatch
This class provides a set of methods and properties that can be used to accurately measure
elapsed time.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the total elapsed time measured by the current instance.static longGets the current timestamp with the highest precision available.booleanGets a value indicating whether theStopwatchtimer is running.voidreset()Stops time interval measurement and resets the elapsed time to zero.voidrestart()Stops time interval measurement, resets the elapsed time to zero, and starts measuring elapsed time.voidstart()Starts, or resumes, measuring elapsed time for an interval.static StopwatchstartNew()Initializes a newStopwatchinstance, sets the elapsed time property to zero, and starts measuring elapsed time.voidstop()Stops measuring elapsed time for an interval.
-
Constructor Details
-
Stopwatch
public Stopwatch()Initializes a new instance of theStopwatchclass.
-
-
Method Details
-
start
public void start()Starts, or resumes, measuring elapsed time for an interval. -
startNew
Initializes a newStopwatchinstance, sets the elapsed time property to zero, and starts measuring elapsed time.- Returns:
- a
Stopwatchthat has just begun measuring elapsed time
-
stop
public void stop()Stops measuring elapsed time for an interval. -
reset
public void reset()Stops time interval measurement and resets the elapsed time to zero. -
restart
public void restart()Stops time interval measurement, resets the elapsed time to zero, and starts measuring elapsed time. -
isRunning
public boolean isRunning()Gets a value indicating whether theStopwatchtimer is running.- Returns:
trueif theStopwatchinstance is currently running and measuring elapsed time for an interval; otherwise,false
-
getElapsed
Gets the total elapsed time measured by the current instance.- Returns:
- a
Durationrepresenting the total elapsed time measured by the current instance
-
getTimestamp
public static long getTimestamp()Gets the current timestamp with the highest precision available. This should use a monotonic clock whenever possible.- Returns:
- a long integer representing the current timestamp
-