more use of the computeAverages method

This commit is contained in:
zab
2012-11-17 18:51:28 +00:00
parent 82e4244473
commit 3cbca7c0ac
3 changed files with 29 additions and 14 deletions

View File

@ -422,6 +422,8 @@ public class Rate {
public synchronized void computeAverages(RateAverages out, boolean useLifetime) {
final long total = _currentEventCount + _lastEventCount;
out.setTotalEventCount(total);
if (total <= 0) {
final double avg = useLifetime ? getAvgOrLifetimeAvg() : getAverageValue();
out.setAverage(avg);

View File

@ -8,11 +8,13 @@ package net.i2p.stat;
public class RateAverages {
private double average, current, last;
private long totalEventCount;
public void reset() {
average = 0;
current = 0;
last = 0;
totalEventCount = 0;
}
public double getAverage() {
@ -39,4 +41,12 @@ public class RateAverages {
this.last = last;
}
public long getTotalEventCount() {
return totalEventCount;
}
public void setTotalEventCount(long totalEventCount) {
this.totalEventCount = totalEventCount;
}
}