/** * Get the current rolling average of the download latency. * @return rolling average of download latency in milliseconds. */ public long getBlockDownloadLatency() { return currentBlockDownloadLatency.getCurrentAverage(); }
/** * Get the current rolling average of the upload latency. * @return rolling average of upload latency in milliseconds. */ public long getBlockUploadLatency() { return currentBlockUploadLatency.getCurrentAverage(); }
/** * Get the current rolling average of the upload latency. * @return rolling average of upload latency in milliseconds. */ public long getBlockUploadLatency() { return currentBlockUploadLatency.getCurrentAverage(); }
/** * Get the current rolling average of the download latency. * @return rolling average of download latency in milliseconds. */ public long getBlockDownloadLatency() { return currentBlockDownloadLatency.getCurrentAverage(); }
@Override public void getMetrics(MetricsCollector builder, boolean all) { averageBlockDownloadLatencyMs.set( currentBlockDownloadLatency.getCurrentAverage()); averageBlockUploadLatencyMs.set( currentBlockUploadLatency.getCurrentAverage()); registry.snapshot(builder.addRecord(registry.info().name()), true); } }
@Override public void getMetrics(MetricsCollector builder, boolean all) { averageBlockDownloadLatencyMs.set( currentBlockDownloadLatency.getCurrentAverage()); averageBlockUploadLatencyMs.set( currentBlockUploadLatency.getCurrentAverage()); registry.snapshot(builder.addRecord(registry.info().name()), true); } }
/** * 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. } }