Class BenchmarkHelper


  • public class BenchmarkHelper
    extends java.lang.Object
    Tools for setting up basic benchmarks. Call benchmark(int, Runnable) with the number of iterations and a Runnable to benchmark to obtain a list of run-times in milliseconds.
    Author:
    Tobias Pietzsch
    • Constructor Summary

      Constructors 
      Constructor Description
      BenchmarkHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.ArrayList<java.lang.Long> benchmark​(int numRuns, java.lang.Runnable benchmark)
      Run a benchmark numRuns times and record the milliseconds taken for each run.
      static void benchmarkAndPrint​(int numRuns, boolean printIndividualTimes, java.lang.Runnable b)
      Run a benchmark numRuns times and print the results to System.out .
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BenchmarkHelper

        public BenchmarkHelper()
    • Method Detail

      • benchmark

        public static java.util.ArrayList<java.lang.Long> benchmark​(int numRuns,
                                                                    java.lang.Runnable benchmark)
        Run a benchmark numRuns times and record the milliseconds taken for each run.
        Parameters:
        numRuns - how many times to run the benchmark.
        benchmark - the benchmark.
        Returns:
        run-times for each run (in milliseconds).
      • benchmarkAndPrint

        public static void benchmarkAndPrint​(int numRuns,
                                             boolean printIndividualTimes,
                                             java.lang.Runnable b)
        Run a benchmark numRuns times and print the results to System.out .
        Parameters:
        numRuns - how many times to run the benchmark.
        printIndividualTimes - whether to print the time for every individual run or just the median.
        b - the benchmark.