Skip to content

Commit

Permalink
freq bench
Browse files Browse the repository at this point in the history
  • Loading branch information
bitfaster committed Nov 21, 2024
1 parent 209d429 commit f973e07
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<LangVersion>13</LangVersion>
<LangVersion>latest</LangVersion>
<TargetFrameworks>net48;net6.0;net8.0</TargetFrameworks>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<!-- https://stackoverflow.com/a/59916801/131345 -->
Expand Down
18 changes: 16 additions & 2 deletions BitFaster.Caching.Benchmarks/Lfu/SketchFrequency.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
namespace BitFaster.Caching.Benchmarks.Lfu
{
[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.Net80)]
[SimpleJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser(displayGenColumns: false)]
[HideColumns("Job", "Median", "RatioSD", "Alloc Ratio")]
[ColumnChart(Title ="Sketch Frequency ({JOB})")]
Expand All @@ -20,6 +22,7 @@ public class SketchFrequency
private CmSketchFlat<int, DetectIsa> flatAvx;

private CmSketchCore<int, DisableHardwareIntrinsics> blockStd;
private CmSketchNoPin<int, DetectIsa> blockAvxNoPin;
private CmSketchCore<int, DetectIsa> blockAvx;

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

blockStd = new CmSketchCore<int, DisableHardwareIntrinsics>(Size, EqualityComparer<int>.Default);
blockAvxNoPin = new CmSketchNoPin<int, DetectIsa>(Size, EqualityComparer<int>.Default);
blockAvx = new CmSketchCore<int, DetectIsa>(Size, EqualityComparer<int>.Default);
}

Expand All @@ -45,7 +49,7 @@ public int FrequencyFlat()
return count;
}

[Benchmark(OperationsPerInvoke = iterations)]
//[Benchmark(OperationsPerInvoke = iterations)]
public int FrequencyFlatAvx()
{
int count = 0;
Expand All @@ -66,7 +70,17 @@ public int FrequencyBlock()
}

[Benchmark(OperationsPerInvoke = iterations)]
public int FrequencyBlockAvx()
public int FrequencyBlockAvxNotPinned()
{
int count = 0;
for (int i = 0; i < iterations; i++)
count += blockAvxNoPin.EstimateFrequency(i) > blockAvx.EstimateFrequency(i + 1) ? 1 : 0;

return count;
}

[Benchmark(OperationsPerInvoke = iterations)]
public int FrequencyBlockAvxPinned()
{
int count = 0;
for (int i = 0; i < iterations; i++)
Expand Down

0 comments on commit f973e07

Please sign in to comment.