Class Stopwatch
- java.lang.Object
-
- implementation.utils.profiling.stopwatches.Stopwatch
-
public class Stopwatch extends java.lang.Object
- Author:
- francesco.bariatti@irisa.fr
-
-
Constructor Summary
Constructors Constructor Description Stopwatch()
-
Method Summary
Modifier and Type Method Description long
getElapsedMilliseconds()
long
getElapsedNanoseconds()
If the stopwatch is running: return elapsed time since the stopwatch has been started.long
getElapsedSeconds()
boolean
isRunning()
void
restart()
Stop and restart the stopwatch.void
resume()
Start the stopwatch, but instead of starting from 0, it starts from the previous elapsed time.void
start()
Start the stopwatch.void
stop()
Stop the stopwatch and store elapsed time.
-
-
-
Method Detail
-
start
public void start()
Start the stopwatch. Only a stopped stopwatch can be started.
-
stop
public void stop()
Stop the stopwatch and store elapsed time. Only a running stopwatch can be stopped.
-
resume
public void resume()
Start the stopwatch, but instead of starting from 0, it starts from the previous elapsed time. If the stopwatch has never been started, it is equivalent to start(). Only a stopped stopwatch can be resumed.
-
restart
public void restart()
Stop and restart the stopwatch. Only a running stopwatch can be restarted.
-
isRunning
public boolean isRunning()
- Returns:
- Whether the stopwatch is running.
-
getElapsedNanoseconds
public long getElapsedNanoseconds()
If the stopwatch is running: return elapsed time since the stopwatch has been started. If the stopwatch is stopped: return time for which the stopwatch has been running.
-
getElapsedMilliseconds
public long getElapsedMilliseconds()
- Returns:
- Same as
getElapsedNanoseconds()
, but the time is in milliseconds.
-
getElapsedSeconds
public long getElapsedSeconds()
- Returns:
- Same as
getElapsedNanoseconds()
, but the time is in seconds.
-
-