diff --git a/core/java/src/net/i2p/stat/Rate.java b/core/java/src/net/i2p/stat/Rate.java index 5f5ad7f1781ce27ac3dc8cff2b04fb2be52b5ebd..f292acb933907ce6da8098abd4769472dacde50a 100644 --- a/core/java/src/net/i2p/stat/Rate.java +++ b/core/java/src/net/i2p/stat/Rate.java @@ -434,7 +434,7 @@ public class Rate { out.setTotalEventCount(total); if (total <= 0) { - final double avg = useLifetime ? getAvgOrLifetimeAvg() : getAverageValue(); + final double avg = useLifetime ? getLifetimeAverageValue() : getAverageValue(); out.setAverage(avg); } else { diff --git a/core/java/src/net/i2p/stat/RateAverages.java b/core/java/src/net/i2p/stat/RateAverages.java index af114ab25f44da43e018af4f3cdce9e19dbfb891..37030f013d10129adfc5b677c7ba089f58197c3d 100644 --- a/core/java/src/net/i2p/stat/RateAverages.java +++ b/core/java/src/net/i2p/stat/RateAverages.java @@ -4,6 +4,7 @@ package net.i2p.stat; * Storage space for computations of various averages. * * @author zab + * @since 0.9.4 */ public class RateAverages { @@ -16,6 +17,7 @@ public class RateAverages { }; /** + * @since 0.9.4 * @return thread-local temp instance. */ public static RateAverages getTemp() { @@ -33,43 +35,67 @@ public class RateAverages { totalValues = 0; } + /** + * @since 0.9.4 + * @return 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 => the current average value + */ public double getAverage() { return average; } - public void setAverage(double average) { + void setAverage(double average) { this.average = average; } + /** + * @since 0.9.4 + * @return the current average == current value / current event count + */ public double getCurrent() { return current; } - public void setCurrent(double current) { + void setCurrent(double current) { this.current = current; } + /** + * @since 0.9.4 + * @return the last average == last value / last event count + */ public double getLast() { return last; } - public void setLast(double last) { + void setLast(double last) { this.last = last; } + /** + * @since 0.9.4 + * @return the total event count == current + last event counts + */ public long getTotalEventCount() { return totalEventCount; } - public void setTotalEventCount(long totalEventCount) { + void setTotalEventCount(long totalEventCount) { this.totalEventCount = totalEventCount; } + /** + * @since 0.9.4 + * @return the total values == current + last values + */ public double getTotalValues() { return totalValues; } - public void setTotalValues(double totalValues) { + void setTotalValues(double totalValues) { this.totalValues = totalValues; }