StatsTimer extends StatsMonitor implements Timer { @Override public void record(long duration, TimeUnit timeUnit) { record(this.timeUnit.convert(duration, timeUnit)); } StatsTimer(MonitorConfig baseConfig, StatsConfig statsConfig);  StatsTimer(MonitorConfig baseConfig, StatsConfig statsConfig, TimeUnit unit);  StatsTimer(MonitorConfig config, StatsConfig statsConfig, TimeUnit unit,
                    ScheduledExecutorService executor); @Override Stopwatch start(); @Override TimeUnit getTimeUnit(); @Override void record(long duration, TimeUnit timeUnit); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode(); long getCount(); long getTotalTime();  }
@Test public void testStats() throws Exception { final StatsTimer timer = newInstance("t1"); final Map<String, Number> expectedValues = new HashMap<>(); final int n = 200 * 1000; expectedValues.put("count", (long) n); expectedValues.put("totalTime", (long) n * (n - 1) / 2); expectedValues.put("stdDev", 57735.17); expectedValues.put("percentile_50", 100 * 1000.0); expectedValues.put("percentile_95", 190 * 1000.0); expectedValues.put("percentile_99", 198 * 1000.0); expectedValues.put("percentile_99.50", 199 * 1000.0); for (int i = 0; i < n; ++i) { timer.record(i); } timer.computeStats(); assertStats(timer.getMonitors(), expectedValues); }