Returns the time period (in milliseconds) that encompasses the data set. Eg, a result of 1000 means there's data that covers a one second period.
Computes the rate of events in terms of events/minute
Computes the rate of events in terms of events/second
Creates a new rate tracker.
By default it does not reset.
Options
Computes the average time between events, as well as the longest and shortest time seen.
Analysis in the form of { min, max, avg }
Mark that an event has happened
Resets the tracker's stored values.
Tracks the rate of events: eg, how many times an event happens per second.
It's also able to compute the min, max and average interval between events.
Example
By default the tracker keeps averaging over all the data it sees. It can be useful to limit it so more accurately tracks changes in frequency.
To do so, pass in options when creating it:
timeoutIntervalis a makes the tracker reset after some period withoutmark()being called.sampleLimitsets an upper bound for how many of the most recent events should we consider. A smaller value means the analysis will be more responsive to changes in data source, at the cost of jitter. A larger value gets a smoother response, at the cost of responsiveness.The way it works under-the-hood is we store the timestamp each time
mark()is called, and use this as the basis for computation.