compareAsyncVsSync method
Compares the performance of synchronous and asynchronous operations.
The iterations
parameter is the number of times to run each operation.
The valueSize
parameter is the size of the value to use (in characters).
Returns a comparison of the benchmark results.
Implementation
Future<BenchmarkComparison> compareAsyncVsSync({
required int iterations,
required int valueSize,
}) async {
// Run synchronous benchmarks
final syncResults = await runComprehensiveBenchmark(
iterations: iterations,
valueSize: valueSize,
useAsync: false,
);
// Run asynchronous benchmarks
final asyncResults = await runComprehensiveBenchmark(
iterations: iterations,
valueSize: valueSize,
useAsync: true,
);
return BenchmarkComparison(
syncResults: syncResults,
asyncResults: asyncResults,
valueSize: valueSize,
iterations: iterations,
);
}