public class TimeIt extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_NB_RUNS
Default number of runs.
|
static long |
DEFAULT_WARMUP_FACTOR
Default warmup factor.
|
| Constructor and Description |
|---|
TimeIt(Runnable benchmarkFunction)
Simple constructor that defines automatically the number of loops that should be performed.
|
TimeIt(Runnable benchmarkFunction,
long nbLoops,
int nbRuns,
boolean warmup)
Main constructor.
|
TimeIt(Runnable benchmarkFunction,
long nbLoops,
int nbRuns,
long nbWarmupLoops)
Main constructor.
|
| Modifier and Type | Method and Description |
|---|---|
double |
getMaxTime()
Returns the maximum time it takes to perform the function to benchmark (evaluated on a batch of
N
loops). |
double |
getMeanTime()
Returns the arithmetic mean of the computation time it takes to perform the function to benchmark (evaluated on a
batch of
N loops). |
double |
getMinTime()
Returns the minimum computation time it takes to perform the function to benchmark (evaluated on a batch of
N loops). |
double |
getStandardDeviationTime()
Returns the standard deviation of the computation time it takes to perform the function to benchmark (evaluated
on a batch of
N loops). |
double[] |
getTimes()
Returns the computation times it takes to perform the function to benchmark on each batch of "nbLoops" runs.
|
static double |
loopsPerSecondEstimator(Runnable benchmarkFunction)
Estimates very approximately the number of loops per seconds that can be done by the provided function.
|
String |
toString()
Returns a string representation of the benchmark evaluation statistical results.
|
public static final int DEFAULT_NB_RUNS
public static final long DEFAULT_WARMUP_FACTOR
public TimeIt(Runnable benchmarkFunction)
It chooses the number of loops so that each of the 7 runs will take around 1 second.
benchmarkFunction - The function to benchmarkpublic TimeIt(Runnable benchmarkFunction, long nbLoops, int nbRuns, boolean warmup)
The function to benchmark will be evaluated nbLoops * nbRuns times.
If the function needs to warmup, it is previously run nbLoops / 10 times which are not taken in account
for the statistics.
benchmarkFunction - The function to benchmarknbLoops - The number of loops to be performednbRuns - The number of runs to be performed (used for the statistics)warmup - true if the function needs to warmup, false otherwisepublic TimeIt(Runnable benchmarkFunction, long nbLoops, int nbRuns, long nbWarmupLoops)
The function to benchmark will be evaluated nbLoops * nbRuns times.
If the function needs to warmup, it is previously run nbWarmupLoops times which are not taken in account
for the statistics.
benchmarkFunction - The function to benchmarknbLoops - The number of loops to be performednbRuns - The number of runs to be performed (used for the statistics)nbWarmupLoops - The number of loops to be performed for warmup the function (should be > 0 to enable to warmup)public double getMeanTime()
N loops).public double getStandardDeviationTime()
N loops).public double getMinTime()
N loops).public double getMaxTime()
N
loops).public double[] getTimes()
public String toString()
public static double loopsPerSecondEstimator(Runnable benchmarkFunction)
The estimation takes around 0.2 seconds (unless 1 run takes more than 0.2).
benchmarkFunction - The function to benchmarkCopyright © 2025 CNES. All rights reserved.