com.h3c.util

## Class ThroughputTracker

- java.lang.Object
- - com.h3c.util.ThroughputTracker

- Direct Known Subclasses:
    ReadOnlyThroughputTracker

      public class ThroughputTracker
      extends Object

  Utility class to accrue count of arbitrary entities and measure throughput. Once frozen the tracker time will stop ticking and no more entities can be added to it.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ThroughputTracker()` Create a new tracker in a reset state.
    `ThroughputTracker(long start, long total, boolean frozen)` Synthesize a throughput tracker from existing data.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(long count)` Add the specified number of entities to the tracker.
    `double` | `duration()` Number of seconds elapsed since the tracker was last reset.
    `void` | `freeze()` Freeze the current throughput tracker in the current state.
    `void` | `reset()` Reset the counts and restart the timer associated with the tracker.
    `double` | `throughput()` Get the number of entities transferred per second.
    `long` | `total()` Get the number of entities accumulated by the tracker.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ThroughputTracker

          public ThroughputTracker()

      Create a new tracker in a reset state.

    - #### ThroughputTracker

          public ThroughputTracker(long start,
                           long total,
                           boolean frozen)

      Synthesize a throughput tracker from existing data.
      Parameters:
        `start` - start time-stamp
        `total` - total number of items to start with
        `frozen` - true if the tracker should be immediately frozen

  - ### Method Detail

    - #### reset

          public void reset()

      Reset the counts and restart the timer associated with the tracker.

    - #### freeze

          public void freeze()

      Freeze the current throughput tracker in the current state. No more bytes can be added to it, and no more time will elapse. The tracker may not be reset to start tracking throughput again.

    - #### add

          public void add(long count)

      Add the specified number of entities to the tracker. No-op if the tracker has been frozen.
      Parameters:
        `count` - number of entities to consider as transfered

    - #### throughput

          public double throughput()

      Get the number of entities transferred per second.
      Returns:
        entities per second throughput

    - #### total

          public long total()

      Get the number of entities accumulated by the tracker.
      Returns:
        number of entities previously added to the tracker via add method

    - #### duration

          public double duration()

      Number of seconds elapsed since the tracker was last reset.
      Returns:
        fractional number of seconds since the last reset

Copyright © 2014. All Rights Reserved.