org.apache.commons.math3
Class PerfTestUtils

java.lang.Object
  extended by org.apache.commons.math3.PerfTestUtils

public class PerfTestUtils
extends Object

Simple benchmarking utilities.


Nested Class Summary
static class PerfTestUtils.RunTest
          Utility class for storing a test label.
 
Field Summary
static double NANO_TO_MILLI
          Nanoseconds to milliseconds conversion factor (1.0E-6).
 
Constructor Summary
PerfTestUtils()
           
 
Method Summary
static StatisticalSummary[] time(int repeatChunk, int repeatStat, boolean runGC, Callable<Double>... methods)
          Timing.
static StatisticalSummary[] timeAndReport(String title, int repeatChunk, int repeatStat, boolean runGC, PerfTestUtils.RunTest... methods)
          Timing and report (to standard output) the average time and standard deviation of a single call.
static StatisticalSummary[] timeAndReport(String title, PerfTestUtils.RunTest... methods)
          Timing and report (to standard output).
static double[][][] timesAndResults(int repeatChunk, int repeatStat, boolean runGC, Callable<Double>... methods)
          Timing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NANO_TO_MILLI

public static final double NANO_TO_MILLI
Nanoseconds to milliseconds conversion factor (1.0E-6).

See Also:
Constant Field Values
Constructor Detail

PerfTestUtils

public PerfTestUtils()
Method Detail

time

public static StatisticalSummary[] time(int repeatChunk,
                                        int repeatStat,
                                        boolean runGC,
                                        Callable<Double>... methods)
Timing.

Parameters:
repeatChunk - Each timing measurement will done done for that number of repeats of the code.
repeatStat - Timing will be averaged over that number of runs.
runGC - Call System.gc() between each timed block. When set to true, the test will run much slower.
methods - Codes being timed.
Returns:
for each of the given methods, a StatisticalSummary of the average times (in milliseconds) taken by a single call to the call method (i.e. the time taken by each timed block divided by repeatChunk).

timesAndResults

public static double[][][] timesAndResults(int repeatChunk,
                                           int repeatStat,
                                           boolean runGC,
                                           Callable<Double>... methods)
Timing.

Parameters:
repeatChunk - Each timing measurement will done done for that number of repeats of the code.
repeatStat - Timing will be averaged over that number of runs.
runGC - Call System.gc() between each timed block. When set to true, the test will run much slower.
methods - Codes being timed.
Returns:
for each of the given methods (first dimension), and each of the repeatStat runs (second dimension):
  • the average time (in milliseconds) taken by a single call to the call method (i.e. the time taken by each timed block divided by repeatChunk)
  • the result returned by the call method.

timeAndReport

public static StatisticalSummary[] timeAndReport(String title,
                                                 int repeatChunk,
                                                 int repeatStat,
                                                 boolean runGC,
                                                 PerfTestUtils.RunTest... methods)
Timing and report (to standard output) the average time and standard deviation of a single call. The timing is performed by calling the time method.

Parameters:
title - Title of the test (for the report).
repeatChunk - Each timing measurement will done done for that number of repeats of the code.
repeatStat - Timing will be averaged over that number of runs.
runGC - Call System.gc() between each timed block. When set to true, the test will run much slower.
methods - Codes being timed.
Returns:
for each of the given methods, a statistics of the average times (in milliseconds) taken by a single call to the call method (i.e. the time taken by each timed block divided by repeatChunk).

timeAndReport

public static StatisticalSummary[] timeAndReport(String title,
                                                 PerfTestUtils.RunTest... methods)
Timing and report (to standard output). This method calls timeAndReport(title, 1000, 10000, false, methods).

Parameters:
title - Title of the test (for the report).
methods - Codes being timed.
Returns:
for each of the given methods, a statistics of the average times (in milliseconds) taken by a single call to the call method (i.e. the time taken by each timed block divided by repeatChunk).


Copyright © 2003-2013 The Apache Software Foundation. All Rights Reserved.