Class Counter

  • public class Counter
    extends Object
    Counting mechanism capable of tracking occurrences and rates.
    • Constructor Summary

      Constructor Description
      Creates a new counter.
      Counter​(long start, long total, long end)
      Creates a new counter in a specific state.
    • Constructor Detail

      • Counter

        public Counter()
        Creates a new counter.
      • Counter

        public Counter​(long start,
                       long total,
                       long end)
        Creates a new counter in a specific state. If non-zero end time is specified, the counter will be frozen.
        start - start time
        total - total number of items to start with
        end - end time; if non-ze
    • Method Detail

      • reset

        public void reset()
        Resets the counter, by zeroing out the count and restarting the timer.
      • freeze

        public void freeze()
        Freezes the counter in the current state including the counts and times.
      • add

        public void add​(long count)
        Adds the specified number of occurrences to the counter. No-op if the counter has been frozen.
        count - number of occurrences
      • throughput

        public double throughput()
        Returns the number of occurrences per second.
        throughput in occurrences per second
      • total

        public long total()
        Returns the total number of occurrences counted.
        number of counted occurrences
      • duration

        public double duration()
        Returns the duration expressed in fractional number of seconds.
        fractional number of seconds since the last reset
      • hashCode

        public int hashCode()
        hashCode in class Object