/** * Get the current average. * @return The current average. */ public synchronized long getCurrentAverage() { cleanupOldPoints(); if (currentPoints.isEmpty()) { return 0; } long sum = 0; for (DataPoint current : currentPoints) { sum += current.getValue(); } return sum / currentPoints.size(); }
/** * Get the current average. * @return The current average. */ public synchronized long getCurrentAverage() { cleanupOldPoints(); if (currentPoints.isEmpty()) { return 0; } long sum = 0; for (DataPoint current : currentPoints) { sum += current.getValue(); } return sum / currentPoints.size(); }
/** * Add a new data point that just happened. * @param value The value of the data point. */ public synchronized void addPoint(long value) { currentPoints.offer(new DataPoint(new Date(), value)); cleanupOldPoints(); }
/** * Add a new data point that just happened. * @param value The value of the data point. */ public synchronized void addPoint(long value) { currentPoints.offer(new DataPoint(new Date(), value)); cleanupOldPoints(); }