Package org.jppf.utils
Class TimeMarker
java.lang.Object
org.jppf.utils.TimeMarker
A simple utility class to measure the elapsed time between two points in the code.
Typicaly it is used as follows:
TimeMarker marker = new TimeMarker().start();
// ... execute some code ...
long elapsed = marker.stop().getLastElapsed();
System.out.println("elapsed time: " + marker.getLastElapsedAsString());- Author:
- Laurent Cohen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintgetCount()Get the count of measurements.longGet the elapsed time for the last measurement.Get the elapsed time for the last measurement formatted as hh:mm:ss.nnnlongGet the elapsed time for the last measurement in milliseconds.longGet the total elapsed time for all measurements in milliseconds.Get the total elapsed time formatted as hh:mm:ss.nnnlongGet the total elapsed time for all measurements.markTime()Take a measurement and recompute the last and total elapsed times.start()Start a new measurement.stop()Stop the current measurement.
-
Constructor Details
-
TimeMarker
public TimeMarker()
-
-
Method Details
-
start
Start a new measurement.- Returns:
- this
TimeMarker.
-
stop
Stop the current measurement.- Returns:
- this
TimeMarker.
-
markTime
Take a measurement and recompute the last and total elapsed times.- Returns:
- this
TimeMarker.
-
getLastElapsed
public long getLastElapsed()Get the elapsed time for the last measurement.- Returns:
- the elapsed time as a
longvalue.
-
getLastElapsedMillis
public long getLastElapsedMillis()Get the elapsed time for the last measurement in milliseconds.- Returns:
- the elapsed time as a
longvalue.
-
getTotalElapsed
public long getTotalElapsed()Get the total elapsed time for all measurements in milliseconds.- Returns:
- the elapsed time as a
longvalue.
-
getTotalElapsedMillis
public long getTotalElapsedMillis()Get the total elapsed time for all measurements.- Returns:
- the elapsed time as a
longvalue.
-
getLastElapsedAsString
Get the elapsed time for the last measurement formatted as hh:mm:ss.nnn- Returns:
- a string representation of the last elapsed time.
-
getTotalElapsedAsString
Get the total elapsed time formatted as hh:mm:ss.nnn- Returns:
- a string representation of the total elapsed time.
-
getCount
public int getCount()Get the count of measurements.- Returns:
- the count as an
intvalue.
-