benchmark<R> function
BenchmarkResult<R>
benchmark<R>(
- String name,
- int loops,
- BenchMarkFunction<
R> f, { - bool verbose = false,
- dynamic printer(
- Object? o
Performas a benchmark of BenchMarkFunction f
.
Implementation
BenchmarkResult<R> benchmark<R>(String name, int loops, BenchMarkFunction<R> f,
{bool verbose = false, Function(Object? o)? printer}) {
var chronometer = BenchmarkResult<R>(name)..start();
var result = f(loops);
chronometer.stop(operations: result.operations);
chronometer._result = result.result;
if (verbose) {
if (printer != null) {
printer(chronometer);
} else {
print(chronometer);
}
}
return chronometer;
}