/** * Timing. * * @param repeatChunk Each timing measurement will done done for that number of repeats of the * code. * @param repeatStat Timing will be averaged over that number of runs. * @param runGC Call {@code System.gc()} between each timed block. When set to {@code true}, the * test will run much slower. * @param methods Codes being timed. * @return for each of the given {@code methods}, a {@link StatisticalSummary} of the average * times (in milliseconds) taken by a single call to the {@code call} method (i.e. the time * taken by each timed block divided by {@code repeatChunk}). */ public static StatisticalSummary[] time( int repeatChunk, int repeatStat, boolean runGC, Callable<Double>... methods) { final double[][][] times = timesAndResults(repeatChunk, repeatStat, runGC, methods); final int len = methods.length; final StatisticalSummary[] stats = new StatisticalSummary[len]; for (int j = 0; j < len; j++) { final SummaryStatistics s = new SummaryStatistics(); for (int k = 0; k < repeatStat; k++) { s.addValue(times[j][k][0]); } stats[j] = s.getSummary(); } return stats; }