public abstract class BenchTest extends Object
A test has three steps:
pre()
: Before launching the test, the test fields and
environment must be initialized during this step. This preparation time is
not accounted for.run()
: The test itself.post()
: After the test execution, this step is called to clean
the test environment.run()
) can contain for any reasons some code which
must not be accounted for. In this case, this peace of code must be ran again
in the emptyRun()
in order to remove this time.
To have good results, the test must be executed several times. To determinate
the available number of iterations, a calibration step is performed during a
time defined by getCalibrationTime()
. In a second time, this number
of iterations is used to reach the bench time specified by
getRunTime()
.
Modifier and Type | Field and Description |
---|---|
protected static long |
CALIBRATION_TIME
Defines the default time (in milliseconds) to calibrate the number of
iterations the test must be ran to reach the expected run time.
|
protected static long |
RUN_TIME
Defines the test run time (in milliseconds)
|
Constructor and Description |
---|
BenchTest() |
Modifier and Type | Method and Description |
---|---|
void |
emptyRun()
Called to remove from full test some time which must not be accounted for
in bench results.
|
protected long |
getCalibrationTime()
Gets the time to calibrate the number of iterations the test must be ran
to reach the expected run time.
|
int |
getNumberOfIterations()
Gets the number of iterations the bench must be ran to reach the bench
time specified by
getRunTime() . |
protected long |
getRunTime()
Gets the time the test must run to perform the bench.
|
void |
post()
Called to clean bench test environment after running the test.
|
void |
pre()
Called to initialize bench test fields and environment before running the
test.
|
abstract void |
run()
Run the full test.
|
protected static final long CALIBRATION_TIME
protected static final long RUN_TIME
public void emptyRun()
protected long getCalibrationTime()
Default returned value is CALIBRATION_TIME
.
public int getNumberOfIterations()
getRunTime()
.
This method can be overrided to force to use a specific number of
iterations without taking in consideration getRunTime()
.
protected long getRunTime()
Default returned value is RUN_TIME
.
public void post()
By default there is noting to clean.
public void pre()
By default there is noting to initialize.
public abstract void run()