/** * Indicate that we just downloaded a block and record its latency. * @param latency The latency in milliseconds. */ public void blockDownloaded(long latency) { currentBlockDownloadLatency.addPoint(latency); }
/** * Indicate that we just uploaded a block and record its latency. * @param latency The latency in milliseconds. */ public void blockUploaded(long latency) { currentBlockUploadLatency.addPoint(latency); }
/** * Indicate that we just downloaded a block and record its latency. * @param latency The latency in milliseconds. */ public void blockDownloaded(long latency) { currentBlockDownloadLatency.addPoint(latency); }
/** * Indicate that we just uploaded a block and record its latency. * @param latency The latency in milliseconds. */ public void blockUploaded(long latency) { currentBlockUploadLatency.addPoint(latency); }
/** * Tests the basic functionality of the class. */ @Test public void testBasicFunctionality() throws Exception { RollingWindowAverage average = new RollingWindowAverage(100); assertEquals(0, average.getCurrentAverage()); // Nothing there yet. average.addPoint(5); assertEquals(5, average.getCurrentAverage()); // One point in there. Thread.sleep(50); average.addPoint(15); assertEquals(10, average.getCurrentAverage()); // Two points in there. Thread.sleep(60); assertEquals(15, average.getCurrentAverage()); // One point retired. Thread.sleep(50); assertEquals(0, average.getCurrentAverage()); // Both points retired. } }
/** * Tests the basic functionality of the class. */ @Test public void testBasicFunctionality() throws Exception { RollingWindowAverage average = new RollingWindowAverage(100); assertEquals(0, average.getCurrentAverage()); // Nothing there yet. average.addPoint(5); assertEquals(5, average.getCurrentAverage()); // One point in there. Thread.sleep(50); average.addPoint(15); assertEquals(10, average.getCurrentAverage()); // Two points in there. Thread.sleep(60); assertEquals(15, average.getCurrentAverage()); // One point retired. Thread.sleep(50); assertEquals(0, average.getCurrentAverage()); // Both points retired. } }