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

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

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