@Test
  public void testGetDurationWithUnit() throws Exception {
    testStopwatch.start();
    Thread.sleep(10);
    testStopwatch.stop();

    assertTrue(testStopwatch.getDuration() > 12);
  }
  @Test
  public void testReset() throws Exception {
    testStopwatch.start();
    Thread.sleep(10);
    testStopwatch.stop();
    assertTrue(testStopwatch.getDuration() > 0);

    testStopwatch.reset();
    assertTrue(testStopwatch.getDuration() == 0);
  }
Example #3
0
 /** {@inheritDoc} */
 @Override
 public void stop() {
   super.stop();
   timer.record(getDuration(), TimeUnit.NANOSECONDS);
 }