this method should be implemented by the concrete benchmark.
this method should be implemented by the concrete benchmark. This method is called by the benchmarking code for a number of times. The GC is called before each call to 'run'.
tearDown
,setUp
The entry point.
The entry point. It takes two arguments:
- argument n
is the number of consecutive runs
- optional argument mult
specifies that the n
runs are repeated
mult
times.
a string that is written at the beginning of the output line that contains the timings.
a string that is written at the beginning of the output line that contains the timings. By default, this is the class name.
Run the benchmark the specified number of times and return a list with the execution times in milliseconds in reverse order of the execution.
Run the benchmark the specified number of times and return a list with the execution times in milliseconds in reverse order of the execution.
...
...
Prepare any data needed by the benchmark, but whose execution time should not be measured.
Prepare any data needed by the benchmark, but whose execution time should not be measured. This method is run before each call to the benchmark payload, 'run'.
Perform cleanup operations after each 'run'.
Perform cleanup operations after each 'run'. For micro benchmarks, think about using the result of 'run' in a way that prevents the JVM to dead-code eliminate the whole 'run' method. For instance, print or write the results to a file. The execution time of this method is not measured.
Benchmark
can be used to quickly turn an existing class into a benchmark. Here is a short example:The
run
method has to be defined by the user, who will perform the timed operation there. Run the benchmark as follows:> scala sort1 5
This will run the benchmark 5 times, forcing a garbage collection between runs, and printing the execution times to stdout.
It is also possible to add a multiplier, so
will run the entire benchmark 10 times, each time for 5 runs.