public DescriptiveStatistics measure(@Nullable Runnable pre,
                                       @NotNull Runnable test,
                                       @Nullable Runnable post) {
    // Warmup phase
    for (int i = 0; i < warmup; i++) {
      if (pre != null) {
        pre.run();
      }
      test.run();
      if (post != null) {
        post.run();
      }
    }
    // Run the benchmark
    DescriptiveStatistics stats = new DescriptiveStatistics();
    for (int i = 0; i < iterations; i++) {
      if (pre != null) {
        pre.run();
      }
      long start = System.nanoTime();
      test.run();
      long end = System.nanoTime();
      stats.addValue((double)(end - start) / scaleFactor);
      if (post != null) {
        post.run();
      }
    }
    return stats;
  }
Run the benchmark and measure run-time statistics in nanoseconds.<p>
Before the run the warm-up phase is executed.
@param pre Optional pre-test setup
@param test Mandatory test
@param post Optional post-test cleanup
@return Statistics describing the results. All times are in nanoseconds.
standalone-metastore/metastore-tools/tools-common/src/main/java/org/apache/hadoop/hive/metastore/tools/MicroBenchmark.java