Package org.deckfour.xes.util
Class XTimer
- java.lang.Object
-
- org.deckfour.xes.util.XTimer
-
public class XTimer extends java.lang.ObjectThis class implements a simple timer that can be used to quickly profile the speed of operations within library components. The timer simply uses the system time for timing, and thus does not incur significant overhead on runtime.- Author:
- Christian W. Guenther (christian@deckfour.org)
-
-
Field Summary
Fields Modifier and Type Field Description static longDAY_MILLISMilliseconds in one day.static longHOUR_MILLISMilliseconds in one hour.static longMINUTE_MILLISMilliseconds in one minute.static longSECOND_MILLISMilliseconds in one second.protected longstartStart time of timer.protected longstopStop time of timer.
-
Constructor Summary
Constructors Constructor Description XTimer()Creates a new timer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.StringformatDuration(long millis)Formats a duration in milliseconds as a pretty-print string.longgetDuration()Retrieve the runtime of the timer.java.lang.StringgetDurationString()Retrieve the runtime of the timer as a pretty-print string.voidstart()Starts the timer.voidstop()Stops the timer (takes time).
-
-
-
Field Detail
-
DAY_MILLIS
public static final long DAY_MILLIS
Milliseconds in one day.- See Also:
- Constant Field Values
-
HOUR_MILLIS
public static final long HOUR_MILLIS
Milliseconds in one hour.- See Also:
- Constant Field Values
-
MINUTE_MILLIS
public static final long MINUTE_MILLIS
Milliseconds in one minute.- See Also:
- Constant Field Values
-
SECOND_MILLIS
public static final long SECOND_MILLIS
Milliseconds in one second.- See Also:
- Constant Field Values
-
start
protected long start
Start time of timer.
-
stop
protected long stop
Stop time of timer.
-
-
Method Detail
-
start
public void start()
Starts the timer.
-
stop
public void stop()
Stops the timer (takes time).
-
getDuration
public long getDuration()
Retrieve the runtime of the timer.- Returns:
- Runtime between start (or creation of timer) and stop, in milliseconds.
-
getDurationString
public java.lang.String getDurationString()
Retrieve the runtime of the timer as a pretty-print string.- Returns:
- Runtime between start (or creation of timer) and stop, as a pretty-print string.
-
formatDuration
public static java.lang.String formatDuration(long millis)
Formats a duration in milliseconds as a pretty-print string.- Parameters:
millis- Duration in milliseconds.- Returns:
- Given duration as a pretty-print string.
-
-