java.lang.Object
net.i2p.stat.RateAverages
Storage space for computations of various averages.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate doubleWeighted average value.private doubleCurrent period average value.private doubleLast period average value.private static final ThreadLocal<RateAverages> Thread-local temp instance.private longSum of current and last event counts.private doubleSum of current and last total values.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptiondoubleThe weighted average.doubleThe current average.doublegetLast()The last average.static RateAveragesgetTemp()Thread-local temp instance.longThe total event count.doubleThe total values.static voidrelease()Remove the thread-local temp instance.(package private) voidreset()Reset all fields to zero.(package private) voidsetAverage(double average) Stores the weighted average.(package private) voidsetCurrent(double current) Stores the current period average.(package private) voidsetLast(double last) Stores the last period average.(package private) voidsetTotalEventCount(long totalEventCount) Stores the total event count.(package private) voidsetTotalValues(double totalValues) Stores the total values sum.
Field Details
TEMP
Thread-local temp instance.average
private double averageWeighted average value.current
private double currentCurrent period average value.last
private double lastLast period average value.totalValues
private double totalValuesSum of current and last total values.totalEventCount
private long totalEventCountSum of current and last event counts.
Constructor Details
RateAverages
public RateAverages()Create a new RateAverages.
Method Details
getTemp
release
public static void release()Remove the thread-local temp instance.reset
void reset()Reset all fields to zero.getAverage
public double getAverage()The weighted average.- Returns:
- one of several things: if there are any events (current or last) => weighted average otherwise if the useLifetime parameter to Rate.computeAverages was: true => the lifetime average value false => zero
setAverage
void setAverage(double average) Stores the weighted average.- Parameters:
average- the combined period average, or the lifetime average if no events were recorded
getCurrent
public double getCurrent()The current average.- Returns:
- the current average == current value / current event count
setCurrent
void setCurrent(double current) Stores the current period average.- Parameters:
current- the current period's value total divided by its event count
getLast
public double getLast()The last average.- Returns:
- the last average == last value / last event count
setLast
void setLast(double last) Stores the last period average.- Parameters:
last- the previous period's value total divided by its event count
getTotalEventCount
public long getTotalEventCount()The total event count.- Returns:
- the total event count == current + last event counts
setTotalEventCount
void setTotalEventCount(long totalEventCount) Stores the total event count.- Parameters:
totalEventCount- the current and previous periods' event counts added together
getTotalValues
public double getTotalValues()The total values.- Returns:
- the total values == current + last values
setTotalValues
void setTotalValues(double totalValues) Stores the total values sum.- Parameters:
totalValues- the current and previous periods' value totals added together