public void pauseAll() { for (MetricMeasurement metric : metricInstances) { metric.pauseOwnTime(); } }
public void stopTimer() { pauseOwnTime(); endValue = metricSource.getValueForThread(thread); }
public void testCannotPauseWhenPaused() { MetricMeasurement timing = new MetricMeasurement(StandardThreadMetrics.CLOCK_TIME, Thread .currentThread()); timing.startTimer(); timing.pauseOwnTime(); try { timing.pauseOwnTime(); fail(); } catch (IllegalStateException e) { // Expected } }
public void testCannotPauseBeforeStarted() { MetricMeasurement timing = new MetricMeasurement(StandardThreadMetrics.CLOCK_TIME, Thread .currentThread()); try { timing.pauseOwnTime(); fail(); } catch (IllegalStateException e) { // Expected } }
public void testCannotPauseAfterStop() { MetricMeasurement timing = new MetricMeasurement(StandardThreadMetrics.CLOCK_TIME, Thread .currentThread()); timing.startTimer(); timing.stopTimer(); try { timing.pauseOwnTime(); fail(); } catch (IllegalStateException e) { // Expected } }
public void testSanityOfNumbers() { // This test is unlikely to ever pick anything up but we may as well sanity check that the // numbers make sense (own time isn't > than total time) MetricMeasurement timing = new MetricMeasurement(StandardThreadMetrics.CLOCK_TIME, Thread .currentThread()); timing.startTimer(); timing.pauseOwnTime(); timing.resumeOwnTime(); timing.stopTimer(); assertTrue(timing.ownTimeValue().getValue().longValue() >= 0); assertTrue(timing.totalValue().getValue().longValue() >= 0); assertTrue(timing.ownTimeValue().getValue().longValue() <= timing.totalValue().getValue().longValue()); }