-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathComparerReadBenchmarks.cs
More file actions
36 lines (30 loc) · 1.01 KB
/
ComparerReadBenchmarks.cs
File metadata and controls
36 lines (30 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
namespace LightningDB.Benchmarks;
/// <summary>
/// Benchmarks read operations across all comparers.
/// Reads use comparers for B-tree traversal during key lookups.
/// </summary>
[MemoryDiagnoser]
public class ComparerReadBenchmarks : ComparerBenchmarkBase
{
[ParamsSource(nameof(AllComparers))]
public override ComparerDescriptor Comparer { get; set; }
public static IEnumerable<ComparerDescriptor> AllComparers => ComparerDescriptor.All;
protected override void RunSetup()
{
// Pre-populate database for reads
using var tx = Env.BeginTransaction();
for (var i = 0; i < KeyBuffers.Count; i++)
tx.Put(DB, KeyBuffers[i], ValueBuffer);
tx.Commit();
}
[Benchmark]
public void Read()
{
using var tx = Env.BeginTransaction(TransactionBeginFlags.ReadOnly);
for (var i = 0; i < OpsPerTransaction; i++) {
_ = tx.Get(DB, KeyBuffers[i]);
}
}
}