com.google.caliper.util.ShortDuration

Here are the examples of the java api class com.google.caliper.util.ShortDuration taken from open source projects.

1. TrialRunLoop#getTrialTimeLimitTrialNanos()

Project: caliper
File: TrialRunLoop.java
private long getTrialTimeLimitTrialNanos() {
    ShortDuration timeLimit = options.timeLimit();
    if (ShortDuration.zero().equals(timeLimit)) {
        return Long.MAX_VALUE;
    }
    return timeLimit.to(NANOSECONDS);
}

2. RuntimeWorkerTest#testCalculateTargetReps_tinyBenchmark()

Project: caliper
File: RuntimeWorkerTest.java
@Test
public void testCalculateTargetReps_tinyBenchmark() {
    // this is one cycle on a 5GHz machine
    ShortDuration oneCycle = ShortDuration.of(new BigDecimal("2.0e-10"), SECONDS);
    long targetReps = calculateTargetReps(INITIAL_REPS, oneCycle.times(INITIAL_REPS).to(NANOSECONDS), TIMING_INTERVAL.to(NANOSECONDS), 0.0);
    long expectedReps = TIMING_INTERVAL.toPicos() / oneCycle.toPicos();
    assertEquals(expectedReps, targetReps);
}