myTotals.delta.addSample(s);
}
long now = System.currentTimeMillis() / 1000;// in seconds
SamplingStatCalculator myDelta = null;
SamplingStatCalculator myTotal = null;
boolean reportNow = false;
/*
* Have we reached the reporting boundary? Need to allow for a margin of
* error, otherwise can miss the slot Also need to check we've not hit
* the window already
*/
synchronized (myTotals) {
if ((now > myTotals.last + INTERVAL_WINDOW) && (now % INTERVAL <= INTERVAL_WINDOW)) {
reportNow = true;
myDelta = new SamplingStatCalculator(myTotals.delta);// copy
// the
// data
// to
// minimise
// ...
myTotals.moveDelta();
myTotal = new SamplingStatCalculator(myTotals.total);// ...
// the
// synch
// time
myTotals.last = now;
}
}
if (reportNow) {
String str;
str = format(myDelta, "+");
if (TOLOG)
log.info(str);
if (TOOUT)
System.out.println(str);
if (myTotal.getCount() != myDelta.getCount()) {// Only if we have
// updated them
str = format(myTotal, "=");
if (TOLOG)
log.info(str);
if (TOOUT)