Skip to content

Commit 34f37a9

Browse files
authored
bench (#159)
1 parent adc24b1 commit 34f37a9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

BitFaster.Caching.Benchmarks/Lru/LruJustGetOrAdd.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public class LruJustGetOrAdd
4444
private static readonly FastConcurrentLru<int, int> fastConcurrentLru = new FastConcurrentLru<int, int>(8, 9, EqualityComparer<int>.Default);
4545
private static readonly FastConcurrentTLru<int, int> fastConcurrentTLru = new FastConcurrentTLru<int, int>(8, 9, EqualityComparer<int>.Default, TimeSpan.FromMinutes(1));
4646

47+
private static readonly ICache<int, int> atomicFastLru = new ConcurrentLruBuilder<int, int>().WithConcurrencyLevel(8).WithCapacity(9).WithAtomicCreate().Build();
48+
4749
private static readonly int key = 1;
4850
private static System.Runtime.Caching.MemoryCache memoryCache = System.Runtime.Caching.MemoryCache.Default;
4951

@@ -78,6 +80,13 @@ public void ConcurrentLru()
7880
concurrentLru.GetOrAdd(1, func);
7981
}
8082

83+
[Benchmark()]
84+
public void AtomicFastLru()
85+
{
86+
Func<int, int> func = x => x;
87+
atomicFastLru.GetOrAdd(1, func);
88+
}
89+
8190
[Benchmark()]
8291
public void FastConcurrentTLru()
8392
{

0 commit comments

Comments
 (0)