BasicTimer extends AbstractMonitor<Long> implements Timer, CompositeMonitor<Long>, SpectatorMonitor { @Override public Long getValue(int pollerIndex) { final long cnt = count.getCurrentCount(pollerIndex); final long value = (long) (getTotal(pollerIndex) / cnt); return (cnt == 0) ? 0L : value; } BasicTimer(MonitorConfig config);   BasicTimer(MonitorConfig config, TimeUnit unit, Clock clock);  BasicTimer(MonitorConfig config, TimeUnit unit); @Override List<Monitor<?>> getMonitors(); @Override Stopwatch start(); @Override TimeUnit getTimeUnit(); @Override @Deprecated void record(long duration); @Override void record(long duration, TimeUnit unit); @Override Long getValue(int pollerIndex); Double getTotalTime(); Long getCount(); Double getMax(); @Override void initializeSpectator(TagList tags); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }
@Test public void testGetValue() throws Exception { BasicTimer c = newInstance("foo"); assertEquals(c.getValue().longValue(), 0L); assertEquals(c.getTotalTime().longValue(), 0L); assertEquals(c.getCount().longValue(), 0L); assertEquals(c.getMax().longValue(), 0L); c.record(42, TimeUnit.MILLISECONDS); assertEquals(c.getValue().longValue(), 42L); assertEquals(c.getTotalTime().longValue(), 42L); assertEquals(c.getCount().longValue(), 1L); assertEquals(c.getMax().longValue(), 42L); c.record(21, TimeUnit.MILLISECONDS); assertEquals(c.getValue().longValue(), 31L); assertEquals(c.getTotalTime().longValue(), 63L); assertEquals(c.getCount().longValue(), 2L); assertEquals(c.getMax().longValue(), 42L); c.record(84, TimeUnit.MILLISECONDS); assertEquals(c.getValue().longValue(), 49L); assertEquals(c.getTotalTime().longValue(), 147L); assertEquals(c.getCount().longValue(), 3L); assertEquals(c.getMax().longValue(), 84L); assertEquals(c.getValue().longValue(), 49L); assertEquals(c.getTotalTime().longValue(), 147L); assertEquals(c.getCount().longValue(), 3L); assertEquals(c.getMax().longValue(), 84L); }