From f973e073417ee69aaf327f602790add849951929 Mon Sep 17 00:00:00 2001 From: Alex Peck Date: Thu, 21 Nov 2024 05:13:02 +0000 Subject: [PATCH] freq bench --- .../BitFaster.Caching.Benchmarks.csproj | 2 +- .../Lfu/SketchFrequency.cs | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/BitFaster.Caching.Benchmarks/BitFaster.Caching.Benchmarks.csproj b/BitFaster.Caching.Benchmarks/BitFaster.Caching.Benchmarks.csproj index df10ca09..789e1174 100644 --- a/BitFaster.Caching.Benchmarks/BitFaster.Caching.Benchmarks.csproj +++ b/BitFaster.Caching.Benchmarks/BitFaster.Caching.Benchmarks.csproj @@ -2,7 +2,7 @@ Exe - 13 + latest net48;net6.0;net8.0 True diff --git a/BitFaster.Caching.Benchmarks/Lfu/SketchFrequency.cs b/BitFaster.Caching.Benchmarks/Lfu/SketchFrequency.cs index b97bc19d..4a95f933 100644 --- a/BitFaster.Caching.Benchmarks/Lfu/SketchFrequency.cs +++ b/BitFaster.Caching.Benchmarks/Lfu/SketchFrequency.cs @@ -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})")] @@ -20,6 +22,7 @@ public class SketchFrequency private CmSketchFlat flatAvx; private CmSketchCore blockStd; + private CmSketchNoPin blockAvxNoPin; private CmSketchCore blockAvx; [Params(32_768, 524_288, 8_388_608, 134_217_728)] @@ -32,6 +35,7 @@ public void Setup() flatAvx = new CmSketchFlat(Size, EqualityComparer.Default); blockStd = new CmSketchCore(Size, EqualityComparer.Default); + blockAvxNoPin = new CmSketchNoPin(Size, EqualityComparer.Default); blockAvx = new CmSketchCore(Size, EqualityComparer.Default); } @@ -45,7 +49,7 @@ public int FrequencyFlat() return count; } - [Benchmark(OperationsPerInvoke = iterations)] + //[Benchmark(OperationsPerInvoke = iterations)] public int FrequencyFlatAvx() { int count = 0; @@ -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++)