Package net.imglib2.util
Class BenchmarkHelper
- java.lang.Object
-
- net.imglib2.util.BenchmarkHelper
-
public class BenchmarkHelper extends java.lang.ObjectTools for setting up basic benchmarks. Callbenchmark(int, Runnable)with the number of iterations and aRunnableto benchmark to obtain a list of run-times in milliseconds.
-
-
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 voidbenchmarkAndPrint(int numRuns, boolean printIndividualTimes, java.lang.Runnable b)Run a benchmark numRuns times and print the results toSystem.out.private static longmedian(java.util.ArrayList<java.lang.Long> values)Compute median of a sorted list ofLongs.
-
-
-
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 toSystem.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.
-
median
private static long median(java.util.ArrayList<java.lang.Long> values)
Compute median of a sorted list ofLongs.- Parameters:
values- sorted list of values.- Returns:
- median of the values.
-
-