diff --git a/benchmarking/java/com/google/j2cl/benchmarking/framework/AbstractBenchmark.java b/benchmarking/java/com/google/j2cl/benchmarking/framework/AbstractBenchmark.java index 5c11de4fad..86c204a0a5 100644 --- a/benchmarking/java/com/google/j2cl/benchmarking/framework/AbstractBenchmark.java +++ b/benchmarking/java/com/google/j2cl/benchmarking/framework/AbstractBenchmark.java @@ -52,4 +52,13 @@ public void tearDown() {} * Called one time after the benchmark is executed. */ public void tearDownOneTime() {} + + /** + * Returns whether the benchmark is long running. + * + *
If the benchmark is long running, the framework uses a longer warmup and measurement time. + */ + public boolean isLongRunning() { + return false; + } } diff --git a/benchmarking/java/com/google/j2cl/benchmarking/framework/BenchmarkExecutor.java b/benchmarking/java/com/google/j2cl/benchmarking/framework/BenchmarkExecutor.java index 3eec1fb68f..d82aa09a1e 100644 --- a/benchmarking/java/com/google/j2cl/benchmarking/framework/BenchmarkExecutor.java +++ b/benchmarking/java/com/google/j2cl/benchmarking/framework/BenchmarkExecutor.java @@ -27,9 +27,13 @@ public final class BenchmarkExecutor { } public static BenchmarkResult execute(AbstractBenchmark benchmark) { - // Run the benchmark with 5 warm-up rounds of 1 second each and then with 5 measurement rounds - // of 1 second each. - return execute(benchmark, Clock.DEFAULT, 10, 5, 1000); + if (benchmark.isLongRunning()) { + // Run the benchmark with 5 warm-up / 5 measurement rounds 10 second each. + return execute(benchmark, Clock.DEFAULT, 10, 5, 10000); + } else { + // Run the benchmark with 5 warm-up / 5 measurement rounds 1 second each. + return execute(benchmark, Clock.DEFAULT, 10, 5, 1000); + } } public static void prepareForRunOnce(AbstractBenchmark benchmark) { @@ -100,7 +104,11 @@ static BenchmarkResult execute( benchmark.tearDownOneTime(); BenchmarkResult benchmarkResult = BenchmarkResult.from(throughputs); - log("Throughput: %s ops/ms", benchmarkResult.getAverageThroughput()); + if (benchmark.isLongRunning()) { + log("Throughput: %s ops/s", benchmarkResult.getAverageThroughput() * 1000); + } else { + log("Throughput: %s ops/ms", benchmarkResult.getAverageThroughput()); + } return benchmarkResult; }