Class Timer

    • Method Detail

      • update

        public void update​(long duration,
                           TimeUnit unit)
        Adds a recorded duration.
        Parameters:
        duration - the length of the duration
        unit - the scale unit of duration
      • update

        public void update​(Duration duration)
        Adds a recorded duration.
        Parameters:
        duration - the Duration to add to the timer. Negative or zero value are ignored.
      • time

        public <T> T time​(Callable<T> event)
                   throws Exception
        Times and records the duration of event.
        Type Parameters:
        T - the type of the value returned by event
        Parameters:
        event - a Callable whose Callable.call() method implements a process whose duration should be timed
        Returns:
        the value returned by event
        Throws:
        Exception - if event throws an Exception
      • timeSupplier

        public <T> T timeSupplier​(Supplier<T> event)
        Times and records the duration of event. Should not throw exceptions, for that use the time(Callable) method.
        Type Parameters:
        T - the type of the value returned by event
        Parameters:
        event - a Supplier whose Supplier.get() method implements a process whose duration should be timed
        Returns:
        the value returned by event
      • time

        public void time​(Runnable event)
        Times and records the duration of event.
        Parameters:
        event - a Runnable whose Runnable.run() method implements a process whose duration should be timed
      • getCount

        public long getCount()
        Description copied from interface: Metered
        Returns the number of events which have been marked.
        Specified by:
        getCount in interface Counting
        Specified by:
        getCount in interface Metered
        Returns:
        the number of events which have been marked
      • getFifteenMinuteRate

        public double getFifteenMinuteRate()
        Description copied from interface: Metered
        Returns the fifteen-minute moving average rate at which events have occurred since the meter was created.
        Specified by:
        getFifteenMinuteRate in interface Metered
        Returns:
        the fifteen-minute moving average rate at which events have occurred since the meter was created
      • getFiveMinuteRate

        public double getFiveMinuteRate()
        Description copied from interface: Metered
        Returns the five-minute moving average rate at which events have occurred since the meter was created.
        Specified by:
        getFiveMinuteRate in interface Metered
        Returns:
        the five-minute moving average rate at which events have occurred since the meter was created
      • getMeanRate

        public double getMeanRate()
        Description copied from interface: Metered
        Returns the mean rate at which events have occurred since the meter was created.
        Specified by:
        getMeanRate in interface Metered
        Returns:
        the mean rate at which events have occurred since the meter was created
      • getOneMinuteRate

        public double getOneMinuteRate()
        Description copied from interface: Metered
        Returns the one-minute moving average rate at which events have occurred since the meter was created.
        Specified by:
        getOneMinuteRate in interface Metered
        Returns:
        the one-minute moving average rate at which events have occurred since the meter was created
      • getSnapshot

        public Snapshot getSnapshot()
        Description copied from interface: Sampling
        Returns a snapshot of the values.
        Specified by:
        getSnapshot in interface Sampling
        Returns:
        a snapshot of the values