The measurement is done by invoking {@link #begin()} and later calling {@link #end()} whichsreturns the time elapsed since the call to {@link #begin()}.
Notice that calls to {@link #begin()} and {@link #end()} can be nested, and each call to{@link #end()} refers to the matching {@link #begin()} call. To ensure that all calls match,the preferred way to write a benchmark is
... Benchmark b = new Benchmark(); ... b.begin(); try { .... } finally { long ms = b.end(); }This code layout also makes it visually easy to write correct pairs of {@link #begin()} /{@link #end()} pairs.
The pair {@link #beginReporting()} and {@link #endReporting()} do basically the same, butreport the benchmarking information through an internal {@link Reporter} object. The default{@link Reporter} prints its messages by System.out.println()
.
Reporting is only enabled if the Benchmark object was created through {@link #Benchmark(boolean)}with a true
argument.
|
|