* Stats: Add API methods for zero duration, for efficiency

This commit is contained in:
zzz
2011-10-15 17:11:40 +00:00
parent a97834d2b7
commit a6ce41fac5
2 changed files with 21 additions and 0 deletions

View File

@ -46,6 +46,17 @@ public class RateStat {
r.addData(value, eventDuration); r.addData(value, eventDuration);
} }
/**
* Update all of the rates for the various periods with the given value.
* Zero duration.
* @since 0.8.10
*/
public void addData(long value) {
if (_statLog != null) _statLog.addData(_groupName, _statName, value, 0);
for (Rate r: _rates.values())
r.addData(value);
}
/** coalesce all the stats */ /** coalesce all the stats */
public void coalesceStats() { public void coalesceStats() {
for (Rate r: _rates.values()){ for (Rate r: _rates.values()){

View File

@ -150,6 +150,16 @@ public class StatManager {
if (stat != null) stat.addData(data, eventDuration); if (stat != null) stat.addData(data, eventDuration);
} }
/**
* Update the given rate statistic, taking note that the given data point was received (and recalculating all rates).
* Zero duration.
* @since 0.8.10
*/
public void addRateData(String name, long data) {
RateStat stat = _rateStats.get(name); // unsynchronized
if (stat != null) stat.addData(data);
}
private int coalesceCounter; private int coalesceCounter;
/** every this many minutes for frequencies */ /** every this many minutes for frequencies */
private static final int FREQ_COALESCE_RATE = 9; private static final int FREQ_COALESCE_RATE = 9;