Class to compute a weighted average byte rate over a specified time interval.

This class continuously tracks data transmission and computes the byte rate based on a weighted average, considering both the duration and the number of bytes in each sample. It allows for real-time monitoring of bandwidth usage and provides mechanisms to dynamically adjust the measurement interval.

Features:

  • Computes the byte rate using a weighted average approach.
  • Allows setting a custom interval for tracking.
  • Supports dynamic clipping to manually shrink the observation window.

Hierarchy

  • ByteRate

Constructors

  • Constructor initializes the ByteRate object with a specified interval (default: 1000ms). It sets up necessary variables to track byte rate over time.

    Parameters

    • Optional interval: number

      Time interval in milliseconds to compute the byte rate.

    Returns ByteRate

Properties

_bytes: any
_clip: any
_interval: any
_samples: any
_time: any
updateSamples: any

Accessors

  • get interval(): number
  • Returns the interval used for computing the byte rate

    Returns number

  • set interval(value): void
  • Sets a new interval for computing the average byte rate

    Parameters

    • value: number

    Returns void

Methods

  • Adds a new byte sample to the tracking system. Updates the list of samples and recomputes the byte rate

    Parameters

    • bytes: number

      Number of bytes added in this interval

    Returns ByteRate

  • Clears all recorded byte rate data.

    Returns ByteRate

  • Clips the byte rate tracking by marking the last sample as clipped. If a previous clip exists, removes the clipped sample and all preceding samples. Allows to shrink the interval manually between two positions.

    Returns ByteRate

  • Computes the exact byte rate in bytes per second

    Returns number

  • Raised when new bytes are added

    Parameters

    • bytes: number

    Returns void

  • Returns the computed byte rate rounded to the nearest integer

    Returns number

Generated using TypeDoc