Package net.i2p.stat
Class Frequency
java.lang.Object
net.i2p.stat.Frequency
public class Frequency extends Object
Manage the calculation of a moving average event frequency over a certain period.
This provides lifetime, and rolling average, frequency counts.
Unlike Rate, it does not support "bucketed" averages.
There is no tracking of the event frequency in the current or last bucket.
There are no buckets at all.
Depending on what you want, a rolling average might be better than buckets.
Or not.
-
Constructor Summary
Constructors Constructor Description Frequency(long period)
-
Method Summary
Modifier and Type Method Description void
eventOccurred()
Take note that a new event occurred, recalculating all the averages and frequenciesdouble
getAverageEventsPerPeriod()
Calculate how many events would occur in a period given the current (rolling) average.double
getAverageInterval()
on average over the last $period, after how many milliseconds are events coming in, as calculated during the last event occurrence?long
getEventCount()
how many events have occurred within the lifetime of this stat?long
getLastEvent()
Deprecated.unuseddouble
getMaxAverageEventsPerPeriod()
Calculate how many events would occur in a period given the maximum rolling average.double
getMinAverageInterval()
Deprecated.unusedlong
getPeriod()
how long is this frequency averaged over? (ms)double
getStrictAverageEventsPerPeriod()
using the strict average interval, how many events occur within an average period?double
getStrictAverageInterval()
Over the lifetime of this stat, without any decay or weighting, what was the average interval between events? (ms)void
recalculate()
Recalculate the averages(package private) void
store(StringBuilder dest)
Appends the data of this frequency to the specified StringBuilder
-
Constructor Details
-
Frequency
public Frequency(long period)- Parameters:
period
- ms
-
-
Method Details
-
getPeriod
public long getPeriod()how long is this frequency averaged over? (ms) -
getLastEvent
Deprecated.unusedwhen did the last event occur? -
getAverageInterval
public double getAverageInterval()on average over the last $period, after how many milliseconds are events coming in, as calculated during the last event occurrence?- Returns:
- milliseconds; returns period + 1 if no events in previous period
-
getMinAverageInterval
Deprecated.unusedwhat is the lowest average interval (aka most frequent) we have seen? (ms)- Returns:
- milliseconds; returns period + 1 if no events in previous period
-
getAverageEventsPerPeriod
public double getAverageEventsPerPeriod()Calculate how many events would occur in a period given the current (rolling) average. Use getStrictAverageInterval() for the real lifetime average. -
getMaxAverageEventsPerPeriod
public double getMaxAverageEventsPerPeriod()Calculate how many events would occur in a period given the maximum rolling average. Use getStrictAverageEventsPerPeriod() for the real lifetime average. -
getStrictAverageInterval
public double getStrictAverageInterval()Over the lifetime of this stat, without any decay or weighting, what was the average interval between events? (ms)- Returns:
- milliseconds; returns Double.MAX_VALUE if no events ever
-
getStrictAverageEventsPerPeriod
public double getStrictAverageEventsPerPeriod()using the strict average interval, how many events occur within an average period? -
getEventCount
public long getEventCount()how many events have occurred within the lifetime of this stat? -
eventOccurred
public void eventOccurred()Take note that a new event occurred, recalculating all the averages and frequencies -
recalculate
public void recalculate()Recalculate the averages -
store
Appends the data of this frequency to the specified StringBuilder- Parameters:
dest
- to append data to- Since:
- 0.9.23
-