jbench.runs
. Before each test is
run, its prepareTest
is called so it can perform any
per-test initialisation (such as preparing test data to sort). The stopwatch
is then started, runTest
is called, and the stopwatch
is stopped. checkResults
is then called so that the
task can check that it has actually done what it should (eg that the
data which should have been sorted is now in the desired order).
After all the tests for a task are completed (and if no errors occur,
ie no exceptions are thrown), the results for the task will then be
displayed. If any test fails, the whole task is deemed to fail. Once
a task has been run, JBench releases its references so that any memory
used may be released. Note, however, that all the instances will be
created before any are run, so expensive initialisations should be
performed in prepareTest
rather than in the task's
constructor. The garbage collector is encouraged to run between the
prepareTest
and runTest
methods in order
to minimise the chances of garbage collection interfering with the
test results.