Package com.google.caliper.util

Examples of com.google.caliper.util.ShortDuration


public class RuntimeWorkerTest {
  private static final ShortDuration TIMING_INTERVAL = ShortDuration.of(100, MILLISECONDS);

  @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);
  }
View Full Code Here


      streamService.stopAsync();
    }
  }

  private long getTrialTimeLimitTrialNanos() {
    ShortDuration timeLimit = options.timeLimit();
    if (ShortDuration.zero().equals(timeLimit)) {
      return Long.MAX_VALUE;
    }
    return timeLimit.to(NANOSECONDS);
  }
View Full Code Here

    void validateMeasurement(Measurement measurement) {
      if (suggestGranularity) {
        double nanos = measurement.value().magnitude() / measurement.weight();
        if (!notifiedAboutGranularity && ((nanos / 1000) > nanoTimeGranularity.to(NANOSECONDS))) {
          notifiedAboutGranularity = true;
          ShortDuration reasonableUpperBound = nanoTimeGranularity.times(1000);
          stderr.printf("INFO: This experiment does not require a microbenchmark. "
              + "The granularity of the timer (%s) is less than 0.1%% of the measured runtime. "
              + "If all experiments for this benchmark have runtimes greater than %s, "
              + "consider the macrobenchmark instrument.%n", nanoTimeGranularity,
              reasonableUpperBound);
View Full Code Here

    @Override
    void validateMeasurement(Measurement measurement) {
      double nanos = measurement.value().magnitude() / measurement.weight();
      if ((nanos / 1000) < nanoTimeGranularity.to(NANOSECONDS)) {
        ShortDuration runtime = ShortDuration.of(BigDecimal.valueOf(nanos), NANOSECONDS);
        throw new TrialFailureException(String.format(
            "This experiment requires a microbenchmark. "
            + "The granularity of the timer (%s) "
            + "is greater than 0.1%% of the measured runtime (%s). "
            + "Use the microbenchmark instrument for accurate measurements.%n",
View Full Code Here

TOP

Related Classes of com.google.caliper.util.ShortDuration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.