Package nzilbb.util
Class Timers
- java.lang.Object
-
- nzilbb.util.Timers
-
public class Timers extends Object
Maintains a set of named timers, primarily for performance tests.- Author:
- Robert Fromont robert@fromont.net.nz
-
-
Constructor Summary
Constructors Constructor Description Timers()
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
durationMilliseconds(String id)
Get the duration of the given timer in milliseconds.double
durationSeconds(String id)
Get the duration of the given timer in seconds.long
end(String id)
Ends a timer and adds the duration to the total for the given ID.LinkedHashMap<String,Long>
getRunningTimers()
Getter forrunningTimers
: Currently running timers - a map of IDs to start times.LinkedHashMap<String,Long>
getTotals()
Getter fortotals
: Timer totals - a map of IDs to total run times.Timers
setRunningTimers(LinkedHashMap<String,Long> newRunningTimers)
Setter forrunningTimers
: Currently running timers - a map of IDs to start times.Timers
setTotals(LinkedHashMap<String,Long> newTotals)
Setter fortotals
: Timer totals - a map of IDs to total run times.long
start(String id)
Start a timer.String
toString()
String representation of the totals.
-
-
-
Method Detail
-
getRunningTimers
public LinkedHashMap<String,Long> getRunningTimers()
Getter forrunningTimers
: Currently running timers - a map of IDs to start times.- Returns:
- Currently running timers - a map of IDs to start times.
-
setRunningTimers
public Timers setRunningTimers(LinkedHashMap<String,Long> newRunningTimers)
Setter forrunningTimers
: Currently running timers - a map of IDs to start times.- Parameters:
newRunningTimers
- Currently running timers - a map of IDs to start times.
-
getTotals
public LinkedHashMap<String,Long> getTotals()
Getter fortotals
: Timer totals - a map of IDs to total run times.- Returns:
- Timer totals - a map of IDs to total run times.
-
setTotals
public Timers setTotals(LinkedHashMap<String,Long> newTotals)
Setter fortotals
: Timer totals - a map of IDs to total run times.- Parameters:
newTotals
- Timer totals - a map of IDs to total run times.
-
start
public long start(String id)
Start a timer.- Parameters:
id
- The ID of the timer.- Returns:
- The current time.
-
end
public long end(String id)
Ends a timer and adds the duration to the total for the given ID.- Parameters:
id
- The ID of the timer.- Returns:
- Duration for this timer in ms.
-
durationMilliseconds
public long durationMilliseconds(String id)
Get the duration of the given timer in milliseconds.- Parameters:
id
-- Returns:
- The duration of the given timer in milliseconds, or 0 if the timer is unknown.
-
durationSeconds
public double durationSeconds(String id)
Get the duration of the given timer in seconds.- Parameters:
id
-- Returns:
- The duration of the given timer in seconds, or 0.0 if the timer is unknown.
-
-