benchmarkDelete method
Runs a benchmark for delete operations.
The keyPrefix
parameter is the prefix for the keys.
The iterations
parameter is the number of times to run the operation.
Returns the benchmark result.
Implementation
Future<BenchmarkResult> benchmarkDelete({
required String keyPrefix,
required int iterations,
}) async {
// First, create the keys
for (int i = 0; i < iterations; i++) {
final key = '$keyPrefix-$i';
await _cache.put(key, 'benchmark-value');
}
return runBenchmark(
operation: () async {
final key = '$keyPrefix-${_deleteCounter++}';
await _cache.delete(key);
},
iterations: iterations,
name: 'Delete',
);
}