exec method
Actual test execution (asynchronous)
Implementation
Future<PerfTestOne> exec({int? maxLaps, Duration? maxSpan}) async {
stopwatch.reset();
final testProc = this.testProc;
if (testProc == null) {
return this;
}
isOutLaps = (maxLaps == null);
num spanAdjustment = 1.0;
if (maxLaps != null) {
laps = maxLaps;
for (var i = 0; i < maxLaps; i++) {
if (!isMyStopwatch) {
stopwatch.start();
}
await testProc(this, i);
stopwatch.stop(); // no need to spend time on checking isMyStopwatch
}
} else if (maxSpan != null) {
laps = 0;
final maxMilliseconds = maxSpan.inMilliseconds;
for (; stopwatch.elapsedMilliseconds < maxMilliseconds; laps++) {
if (!isMyStopwatch) {
stopwatch.start();
}
await testProc(this, laps);
stopwatch.stop(); // no need to spend time on checking isMyStopwatch
}
if (maxMilliseconds == 0) {
spanAdjustment = 0;
} else {
spanAdjustment = stopwatch.elapsedMilliseconds / maxMilliseconds;
}
}
_setSpan(maxSpan, spanAdjustment);
_output();
return this;
}