I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit a6ce41fa authored by zzz's avatar zzz
Browse files

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

parent a97834d2
No related branches found
No related tags found
No related merge requests found
...@@ -46,6 +46,17 @@ public class RateStat { ...@@ -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()){
......
...@@ -150,6 +150,16 @@ public class StatManager { ...@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment