Class TimeRecorder

  • All Implemented Interfaces:
    Recorder<Long>

    public class TimeRecorder
    extends Object
    implements Recorder<Long>
    Utility class to record duration statistics.
    Since:
    jadice server 4.3.1.1
    • Constructor Detail

      • TimeRecorder

        public TimeRecorder​(int numberRecentObservations)
        Create a new statistic recorder
        Parameters:
        numberRecentObservations - number of observations that are not aggregated and can be retrieved via the getRecent* methods.
    • Method Detail

      • addObservation

        public void addObservation​(Long milliseconds)
        Add an observation.
        Specified by:
        addObservation in interface Recorder<Long>
        Parameters:
        milliseconds - Duration of the observation in milliseconds
      • addObservation

        public void addObservation​(long duration,
                                   TimeUnit unit)
        Add an observation.
        Parameters:
        duration - Duration of the observation
        unit - TimeUnit of the observation.
      • getNumberOfObservations

        public long getNumberOfObservations()
        Returns:
        The number of observations recorded so far.
      • getMaximum

        public long getMaximum()
        Returns:
        The maximum duration in milliseconds of all observations for far. Is 0 if there are no observations yet.
      • getMinimun

        public long getMinimun()
        Returns:
        The minimum duration in milliseconds of all observations for far. Is 0 if there are no observations yet.
      • getAverage

        public long getAverage()
        Returns:
        The average duration in milliseconds of all observations for far. Is 0 if there are no observations yet.
      • getRecentMaximum

        public long getRecentMaximum()
        Returns:
        The maximum duration in milliseconds of the recent observations. Is 0 if there are no observations yet.
      • getRecentMinimum

        public long getRecentMinimum()
        Returns:
        The minimum duration in milliseconds of the recent observations. Is 0 if there are no observations yet.
      • getRecentAverage

        public long getRecentAverage()
        Returns:
        The average duration in milliseconds of the recent observations. Is 0 if there are no observations yet.
      • getLastObservation

        public long getLastObservation()
        Returns:
        The duration in milliseconds of the last observation. Is 0 if there are no observations yet.
      • reset

        public void reset()
        Clear all data recorded so far.
        Specified by:
        reset in interface Recorder<Long>