Skip to content

Commit f973e07

Browse files
committed
freq bench
1 parent 209d429 commit f973e07

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

BitFaster.Caching.Benchmarks/BitFaster.Caching.Benchmarks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<LangVersion>13</LangVersion>
5+
<LangVersion>latest</LangVersion>
66
<TargetFrameworks>net48;net6.0;net8.0</TargetFrameworks>
77
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
88
<!-- https://stackoverflow.com/a/59916801/131345 -->

BitFaster.Caching.Benchmarks/Lfu/SketchFrequency.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
namespace BitFaster.Caching.Benchmarks.Lfu
99
{
1010
[SimpleJob(RuntimeMoniker.Net60)]
11+
[SimpleJob(RuntimeMoniker.Net80)]
12+
[SimpleJob(RuntimeMoniker.Net90)]
1113
[MemoryDiagnoser(displayGenColumns: false)]
1214
[HideColumns("Job", "Median", "RatioSD", "Alloc Ratio")]
1315
[ColumnChart(Title ="Sketch Frequency ({JOB})")]
@@ -20,6 +22,7 @@ public class SketchFrequency
2022
private CmSketchFlat<int, DetectIsa> flatAvx;
2123

2224
private CmSketchCore<int, DisableHardwareIntrinsics> blockStd;
25+
private CmSketchNoPin<int, DetectIsa> blockAvxNoPin;
2326
private CmSketchCore<int, DetectIsa> blockAvx;
2427

2528
[Params(32_768, 524_288, 8_388_608, 134_217_728)]
@@ -32,6 +35,7 @@ public void Setup()
3235
flatAvx = new CmSketchFlat<int, DetectIsa>(Size, EqualityComparer<int>.Default);
3336

3437
blockStd = new CmSketchCore<int, DisableHardwareIntrinsics>(Size, EqualityComparer<int>.Default);
38+
blockAvxNoPin = new CmSketchNoPin<int, DetectIsa>(Size, EqualityComparer<int>.Default);
3539
blockAvx = new CmSketchCore<int, DetectIsa>(Size, EqualityComparer<int>.Default);
3640
}
3741

@@ -45,7 +49,7 @@ public int FrequencyFlat()
4549
return count;
4650
}
4751

48-
[Benchmark(OperationsPerInvoke = iterations)]
52+
//[Benchmark(OperationsPerInvoke = iterations)]
4953
public int FrequencyFlatAvx()
5054
{
5155
int count = 0;
@@ -66,7 +70,17 @@ public int FrequencyBlock()
6670
}
6771

6872
[Benchmark(OperationsPerInvoke = iterations)]
69-
public int FrequencyBlockAvx()
73+
public int FrequencyBlockAvxNotPinned()
74+
{
75+
int count = 0;
76+
for (int i = 0; i < iterations; i++)
77+
count += blockAvxNoPin.EstimateFrequency(i) > blockAvx.EstimateFrequency(i + 1) ? 1 : 0;
78+
79+
return count;
80+
}
81+
82+
[Benchmark(OperationsPerInvoke = iterations)]
83+
public int FrequencyBlockAvxPinned()
7084
{
7185
int count = 0;
7286
for (int i = 0; i < iterations; i++)

0 commit comments

Comments
 (0)