runComprehensiveBenchmark method
Runs a comprehensive benchmark suite.
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).
The useAsync
parameter determines whether to use the asynchronous methods.
Returns a list of benchmark results.
Implementation
Future<List<BenchmarkResult>> runComprehensiveBenchmark({
required int iterations,
required int valueSize,
bool useAsync = false,
}) async {
final results = <BenchmarkResult>[];
// Generate a test value of the specified size
final value = 'A' * valueSize;
// Benchmark put operations
results.add(await benchmarkPut(
keyPrefix: 'benchmark-put',
value: value,
iterations: iterations,
useAsync: useAsync,
));
// Benchmark get operations
final getKey = 'benchmark-get';
await _cache.put(getKey, value);
results.add(await benchmarkGet(
key: getKey,
iterations: iterations,
useAsync: useAsync,
));
// Benchmark delete operations
results.add(await benchmarkDelete(
keyPrefix: 'benchmark-delete',
iterations: iterations,
));
return results;
}