Package net.snowflake.client.util
Class Stopwatch
- java.lang.Object
-
- net.snowflake.client.util.Stopwatch
-
@SnowflakeJdbcInternalApi public class Stopwatch extends Object
Stopwatch class used to calculate the time between start and stop.
-
-
Constructor Summary
Constructors Constructor Description Stopwatch()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
elapsedMillis()
Get the elapsed time (in ms) between the stopTime and startTime.long
elapsedNanos()
Get the elapsed time (in nanoseconds) between the stopTime and startTime.boolean
isStarted()
Get the instance status.void
reset()
Resets the instance to it's initial state.void
restart()
Restarts the instance.void
start()
Starts the Stopwatch.void
stop()
Stops the Stopwatch.
-
-
-
Method Detail
-
start
public void start()
Starts the Stopwatch.- Throws:
IllegalStateException
- when Stopwatch is already running.
-
stop
public void stop()
Stops the Stopwatch.- Throws:
IllegalStateException
- when Stopwatch was not yet started or is already stopped.
-
reset
public void reset()
Resets the instance to it's initial state.
-
restart
public void restart()
Restarts the instance.
-
elapsedMillis
public long elapsedMillis()
Get the elapsed time (in ms) between the stopTime and startTime.- Returns:
- elapsed milliseconds between stopTime and startTime
- Throws:
IllegalStateException
- when Stopwatch has not been started yet
-
elapsedNanos
public long elapsedNanos()
Get the elapsed time (in nanoseconds) between the stopTime and startTime.- Returns:
- elapsed nanoseconds between stopTime and startTime
- Throws:
IllegalStateException
- when Stopwatch has not been started yet
-
isStarted
public boolean isStarted()
Get the instance status.- Returns:
- true if the stopwatch is running, false otherwise
-
-