Package org.apache.camel.util
Class StopWatch
java.lang.Object
org.apache.camel.util.StopWatch
A very simple stop watch.
This implementation is not thread safe and can only time one task at any given time.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longelapsedMillisSince(long start) Deprecated.booleanWhether the watch is startedvoidrestart()Starts or restarts the stop watchlongtaken()Returns the time taken in millis.longReturns the time taken in millis and restarts the timer.
-
Constructor Details
-
StopWatch
public StopWatch()Starts the stop watch -
StopWatch
Starts the stop watch from the given timestamp -
StopWatch
Creates the stop watch- Parameters:
start- whether it should start immediately
-
-
Method Details
-
restart
Starts or restarts the stop watch -
isStarted
Whether the watch is started -
taken
Returns the time taken in millis.- Returns:
- time in millis, or 0 if not started yet.
-
takenAndRestart
Returns the time taken in millis and restarts the timer.- Returns:
- time in millis, or 0 if not started yet.
-
elapsedMillisSince
Deprecated.Utility method to provide the elapsed time using milliseconds since epoch. This serves as an alternative for the former constructor based on a Date argument. This should be used only when converting old code that relies on that constructor as it can provide incorrect measurements in rare circumstances- Parameters:
start- the timestamp in milliseconds since epoch- Returns:
- the elapsed time in milliseconds
-