Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions BitFaster.Caching.Benchmarks/AltBenchmark.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using BitFaster.Caching.Lru;

namespace BitFaster.Caching.Benchmarks
{
[MemoryDiagnoser]
[HideColumns("Job", "Median", "RatioSD")]
public class AltBenchmark
{
private static readonly ConcurrentLru<string, int> concurrentLru = new ConcurrentLru<string, int>(8, 9, EqualityComparer<string>.Default);

[GlobalSetup]
public void GlobalSetup()
{
concurrentLru.AddOrUpdate("1", 1);
}

#if NET9_0_OR_GREATER

[Benchmark(Baseline = true)]
public int GetAlternateInline()
{
var alt = concurrentLru.GetAlternateLookup<ReadOnlySpan<char>>();
alt.TryGet("1", out int value);
return value;
}

[Benchmark()]
public int GetAlternateNoInline()
{
var alt = concurrentLru.GetAlternateLookup2<ReadOnlySpan<char>>();
alt.TryGet("1", out int value);
return value;
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<LangVersion>latest</LangVersion>
<TargetFrameworks>net48;net6.0;net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net10.0;net9.0;net48;net6.0;net8.0;</TargetFrameworks>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<!-- https://stackoverflow.com/a/59916801/131345 -->
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
Expand Down
16 changes: 14 additions & 2 deletions BitFaster.Caching/Lru/ConcurrentLruCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -903,10 +903,11 @@
}

return new(new Proxy(lru));
}

}
#if NET9_0_OR_GREATER
///<inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public IAlternateLookup<TAlternateKey, K, V> GetAlternateLookup<TAlternateKey>()
where TAlternateKey : notnull, allows ref struct
{
Expand All @@ -918,6 +919,17 @@
return new AlternateLookup<TAlternateKey>(this);
}

public IAlternateLookup<TAlternateKey, K, V> GetAlternateLookup2<TAlternateKey>()

Check warning on line 922 in BitFaster.Caching/Lru/ConcurrentLruCore.cs

View workflow job for this annotation

GitHub Actions / infer

Missing XML comment for publicly visible type or member 'ConcurrentLruCore<K, V, I, P, T>.GetAlternateLookup2<TAlternateKey>()'

Check warning on line 922 in BitFaster.Caching/Lru/ConcurrentLruCore.cs

View workflow job for this annotation

GitHub Actions / infer

Missing XML comment for publicly visible type or member 'ConcurrentLruCore<K, V, I, P, T>.GetAlternateLookup2<TAlternateKey>()'

Check warning on line 922 in BitFaster.Caching/Lru/ConcurrentLruCore.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Missing XML comment for publicly visible type or member 'ConcurrentLruCore<K, V, I, P, T>.GetAlternateLookup2<TAlternateKey>()'

Check warning on line 922 in BitFaster.Caching/Lru/ConcurrentLruCore.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Missing XML comment for publicly visible type or member 'ConcurrentLruCore<K, V, I, P, T>.GetAlternateLookup2<TAlternateKey>()'

Check warning on line 922 in BitFaster.Caching/Lru/ConcurrentLruCore.cs

View workflow job for this annotation

GitHub Actions / net48 windows-latest

Missing XML comment for publicly visible type or member 'ConcurrentLruCore<K, V, I, P, T>.GetAlternateLookup2<TAlternateKey>()'

Check warning on line 922 in BitFaster.Caching/Lru/ConcurrentLruCore.cs

View workflow job for this annotation

GitHub Actions / net48 windows-latest

Missing XML comment for publicly visible type or member 'ConcurrentLruCore<K, V, I, P, T>.GetAlternateLookup2<TAlternateKey>()'

Check warning on line 922 in BitFaster.Caching/Lru/ConcurrentLruCore.cs

View workflow job for this annotation

GitHub Actions / net6.0 ubuntu-latest

Missing XML comment for publicly visible type or member 'ConcurrentLruCore<K, V, I, P, T>.GetAlternateLookup2<TAlternateKey>()'

Check warning on line 922 in BitFaster.Caching/Lru/ConcurrentLruCore.cs

View workflow job for this annotation

GitHub Actions / net6.0 ubuntu-latest

Missing XML comment for publicly visible type or member 'ConcurrentLruCore<K, V, I, P, T>.GetAlternateLookup2<TAlternateKey>()'

Check warning on line 922 in BitFaster.Caching/Lru/ConcurrentLruCore.cs

View workflow job for this annotation

GitHub Actions / net6.0 macos-latest

Missing XML comment for publicly visible type or member 'ConcurrentLruCore<K, V, I, P, T>.GetAlternateLookup2<TAlternateKey>()'

Check warning on line 922 in BitFaster.Caching/Lru/ConcurrentLruCore.cs

View workflow job for this annotation

GitHub Actions / net6.0 macos-latest

Missing XML comment for publicly visible type or member 'ConcurrentLruCore<K, V, I, P, T>.GetAlternateLookup2<TAlternateKey>()'

Check warning on line 922 in BitFaster.Caching/Lru/ConcurrentLruCore.cs

View workflow job for this annotation

GitHub Actions / netcoreapp3.1 windows-latest

Missing XML comment for publicly visible type or member 'ConcurrentLruCore<K, V, I, P, T>.GetAlternateLookup2<TAlternateKey>()'

Check warning on line 922 in BitFaster.Caching/Lru/ConcurrentLruCore.cs

View workflow job for this annotation

GitHub Actions / netcoreapp3.1 windows-latest

Missing XML comment for publicly visible type or member 'ConcurrentLruCore<K, V, I, P, T>.GetAlternateLookup2<TAlternateKey>()'

Check warning on line 922 in BitFaster.Caching/Lru/ConcurrentLruCore.cs

View workflow job for this annotation

GitHub Actions / net6.0 windows-latest

Missing XML comment for publicly visible type or member 'ConcurrentLruCore<K, V, I, P, T>.GetAlternateLookup2<TAlternateKey>()'

Check warning on line 922 in BitFaster.Caching/Lru/ConcurrentLruCore.cs

View workflow job for this annotation

GitHub Actions / net6.0 windows-latest

Missing XML comment for publicly visible type or member 'ConcurrentLruCore<K, V, I, P, T>.GetAlternateLookup2<TAlternateKey>()'

Check warning on line 922 in BitFaster.Caching/Lru/ConcurrentLruCore.cs

View workflow job for this annotation

GitHub Actions / net9.0 windows-latest

Missing XML comment for publicly visible type or member 'ConcurrentLruCore<K, V, I, P, T>.GetAlternateLookup2<TAlternateKey>()'

Check warning on line 922 in BitFaster.Caching/Lru/ConcurrentLruCore.cs

View workflow job for this annotation

GitHub Actions / net9.0 windows-latest

Missing XML comment for publicly visible type or member 'ConcurrentLruCore<K, V, I, P, T>.GetAlternateLookup2<TAlternateKey>()'

Check warning on line 922 in BitFaster.Caching/Lru/ConcurrentLruCore.cs

View workflow job for this annotation

GitHub Actions / bench-linux

Missing XML comment for publicly visible type or member 'ConcurrentLruCore<K, V, I, P, T>.GetAlternateLookup2<TAlternateKey>()'

Check warning on line 922 in BitFaster.Caching/Lru/ConcurrentLruCore.cs

View workflow job for this annotation

GitHub Actions / bench-linux

Missing XML comment for publicly visible type or member 'ConcurrentLruCore<K, V, I, P, T>.GetAlternateLookup2<TAlternateKey>()'

Check warning on line 922 in BitFaster.Caching/Lru/ConcurrentLruCore.cs

View workflow job for this annotation

GitHub Actions / bench-win

Missing XML comment for publicly visible type or member 'ConcurrentLruCore<K, V, I, P, T>.GetAlternateLookup2<TAlternateKey>()'

Check warning on line 922 in BitFaster.Caching/Lru/ConcurrentLruCore.cs

View workflow job for this annotation

GitHub Actions / bench-win

Missing XML comment for publicly visible type or member 'ConcurrentLruCore<K, V, I, P, T>.GetAlternateLookup2<TAlternateKey>()'

Check warning on line 922 in BitFaster.Caching/Lru/ConcurrentLruCore.cs

View workflow job for this annotation

GitHub Actions / bench-macos

Missing XML comment for publicly visible type or member 'ConcurrentLruCore<K, V, I, P, T>.GetAlternateLookup2<TAlternateKey>()'

Check warning on line 922 in BitFaster.Caching/Lru/ConcurrentLruCore.cs

View workflow job for this annotation

GitHub Actions / bench-macos

Missing XML comment for publicly visible type or member 'ConcurrentLruCore<K, V, I, P, T>.GetAlternateLookup2<TAlternateKey>()'
where TAlternateKey : notnull, allows ref struct
{
if (!this.dictionary.IsCompatibleKey<TAlternateKey, K, I>())
{
Throw.IncompatibleComparer();
}

return new AlternateLookup<TAlternateKey>(this);
}

///<inheritdoc/>
public bool TryGetAlternateLookup<TAlternateKey>([MaybeNullWhen(false)] out IAlternateLookup<TAlternateKey, K, V> lookup)
where TAlternateKey : notnull, allows ref struct
Expand Down
Loading