Package org.opendaylight.yangtools.util
Class DurationStatisticsTracker
java.lang.Object
org.opendaylight.yangtools.util.DurationStatisticsTracker
Abstract class that calculates and tracks time duration statistics.
- Author:
- Thomas Pantelis, Robert Varga
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
addDuration
(long duration) Add a duration to track.static DurationStatisticsTracker
Create a concurrentDurationStatisticsTracker
, which performs well in very contended environments.static DurationStatisticsTracker
Create a synchronizedDurationStatisticsTracker
, which performs well in non-contended environments.abstract double
Returns the average duration in nanoseconds.final String
Returns the average duration as a displayable String with units, e.g.final String
Returns the longest duration as a displayable String with units and the date/time at which it occurred, e.g.final String
Returns the shortest duration as a displayable String with units and the date/time at which it occurred, e.g.final long
Returns the longest duration in nanoseconds.final long
Returns the shortest duration in nanoseconds.final long
Returns the time stamp of the longest duration.final long
Returns the time stamp of the shortest duration.abstract long
Returns the total number of tracked durations.abstract void
reset()
Resets all statistics back to their defaults.
-
Constructor Details
-
DurationStatisticsTracker
public DurationStatisticsTracker()
-
-
Method Details
-
createConcurrent
Create a concurrentDurationStatisticsTracker
, which performs well in very contended environments.- Returns:
- A new instance.
-
createSynchronized
Create a synchronizedDurationStatisticsTracker
, which performs well in non-contended environments.- Returns:
- A new instance.
-
addDuration
public abstract void addDuration(long duration) Add a duration to track.- Parameters:
duration
- non-negative duration in nanoseconds.
-
getAverageDuration
public abstract double getAverageDuration()Returns the average duration in nanoseconds.- Returns:
- average duration in nanoseconds.
-
getTotalDurations
public abstract long getTotalDurations()Returns the total number of tracked durations.- Returns:
- Total number of measurements accumulated since last
reset()
.
-
reset
public abstract void reset()Resets all statistics back to their defaults. -
getLongestDuration
public final long getLongestDuration()Returns the longest duration in nanoseconds.- Returns:
- the longest duration in nanoseconds.
-
getShortestDuration
public final long getShortestDuration()Returns the shortest duration in nanoseconds.- Returns:
- the shortest duration in nanoseconds.
-
getDisplayableAverageDuration
Returns the average duration as a displayable String with units, e.g.12.34 ms
.- Returns:
- the average duration in human-readable form.
-
getDisplayableLongestDuration
Returns the longest duration as a displayable String with units and the date/time at which it occurred, e.g.12.34 ms at 08/02/2014 12:30:24
.- Returns:
- The longest duration and when it has occurred in human-readable form.
-
getDisplayableShortestDuration
Returns the shortest duration as a displayable String with units and the date/time at which it occurred, e.g.12.34 ms at 08/02/2014 12:30:24
.- Returns:
- The shortest duration and when it has occurred in human-readable form.
-
getTimeOfLongestDuration
public final long getTimeOfLongestDuration()Returns the time stamp of the longest duration.- Returns:
- the time stamp of the longest duration.
-
getTimeOfShortestDuration
public final long getTimeOfShortestDuration()Returns the time stamp of the shortest duration.- Returns:
- the time stamp of the shortest duration.
-