Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<LangVersion>latest</LangVersion>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.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>
2 changes: 1 addition & 1 deletion BitFaster.Caching.Benchmarks/DataStructureBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ namespace BitFaster.Caching.Benchmarks
#if Windows
[SimpleJob(RuntimeMoniker.Net48)]
#endif
[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser(displayGenColumns: false)]
public class DataStructureBenchmarks
{
2 changes: 1 addition & 1 deletion BitFaster.Caching.Benchmarks/DisposerBench.cs
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ namespace BitFaster.Caching.Benchmarks
[DisassemblyDiagnoser(printSource: true, maxDepth: 3)]
[SimpleJob(RuntimeMoniker.Net48)]
#endif
[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.Net90)]
[MemoryDiagnoser(displayGenColumns: false)]
[HideColumns("Job", "Median", "RatioSD", "Alloc Ratio")]
public class DisposerBench
4 changes: 2 additions & 2 deletions BitFaster.Caching.Benchmarks/DrainBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ namespace BitFaster.Caching.Benchmarks
[DisassemblyDiagnoser(printSource: true, maxDepth: 3)]
[SimpleJob(RuntimeMoniker.Net48)]
#endif
[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.Net90)]
[HideColumns("Job", "Median", "RatioSD", "Alloc Ratio")]
public class DrainBenchmarks
{
@@ -187,7 +187,7 @@ public void Add()
public void DrainArray()
{
Add();
#if NETCOREAPP3_1_OR_GREATER
#if NET
buffer.DrainTo(output.AsSpan());
#else
buffer.DrainTo(new ArraySegment<string>(output));
8 changes: 4 additions & 4 deletions BitFaster.Caching.Benchmarks/Lfu/CmSketchFlat.cs
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
using System.Text;
using System.Threading.Tasks;

#if NETCOREAPP3_1_OR_GREATER
#if NET
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
#endif
@@ -53,7 +53,7 @@ public CmSketchFlat(long maximumSize, IEqualityComparer<T> comparer)
/// <returns>The estimated frequency of the value.</returns>
public int EstimateFrequency(T value)
{
#if !NETCOREAPP3_1_OR_GREATER
#if !NET
return EstimateFrequencyStd(value);
#else

@@ -76,7 +76,7 @@ public int EstimateFrequency(T value)
/// <param name="value">The value.</param>
public void Increment(T value)
{
#if !NETCOREAPP3_1_OR_GREATER
#if !NET
IncrementStd(value);
#else

@@ -207,7 +207,7 @@ private int Spread(int x)
return (int)((y >> 16) ^ y);
}

#if NETCOREAPP3_1_OR_GREATER
#if NET
private unsafe int EstimateFrequencyAvx(T value)
{
int hash = Spread(comparer.GetHashCode(value));
19 changes: 7 additions & 12 deletions BitFaster.Caching.Benchmarks/Lfu/CmSketchNoPin.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;


#if NET6_0_OR_GREATER
#if NET
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;
using System.Runtime.Intrinsics.X86;
@@ -57,7 +56,7 @@ public CmSketchNoPin(long maximumSize, IEqualityComparer<T> comparer)
/// <returns>The estimated frequency of the value.</returns>
public int EstimateFrequency(T value)
{
#if NET48
#if NETFRAMEWORK
return EstimateFrequencyStd(value);
#else

@@ -67,7 +66,7 @@ public int EstimateFrequency(T value)
{
return EstimateFrequencyAvx(value);
}
#if NET6_0_OR_GREATER
#if NET
else if (isa.IsArm64Supported)
{
return EstimateFrequencyArm(value);
@@ -86,7 +85,7 @@ public int EstimateFrequency(T value)
/// <param name="value">The value.</param>
public void Increment(T value)
{
#if NET48
#if NETFRAMEWORK
IncrementStd(value);
#else

@@ -96,7 +95,7 @@ public void Increment(T value)
{
IncrementAvx(value);
}
#if NET6_0_OR_GREATER
#if NET
else if (isa.IsArm64Supported)
{
IncrementArm(value);
@@ -233,7 +232,7 @@ private void Reset()
size = (size - (count0 >> 2)) >> 1;
}

#if NET6_0_OR_GREATER
#if NET
private unsafe int EstimateFrequencyAvx(T value)
{
int blockHash = Spread(comparer.GetHashCode(value));
@@ -267,11 +266,7 @@ private unsafe int EstimateFrequencyAvx(T value)
.AsUInt16();

// set the zeroed high parts of the long value to ushort.Max
#if NET6_0
count = Avx2.Blend(count, Vector128<ushort>.AllBitsSet, 0b10101010);
#else
count = Avx2.Blend(count, Vector128.Create(ushort.MaxValue), 0b10101010);
#endif

return Avx2.MinHorizontal(count).GetElement(0);
}
@@ -333,7 +328,7 @@ private unsafe void IncrementAvx(T value)
}
#endif

#if NET6_0_OR_GREATER
#if NET
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private unsafe void IncrementArm(T value)
{
2 changes: 1 addition & 1 deletion BitFaster.Caching.Benchmarks/TimeBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ public int EnvironmentTickCount()
[Benchmark()]
public long EnvironmentTickCount64()
{
#if NETCOREAPP3_0_OR_GREATER
#if NET
return Environment.TickCount64;
#else
return 0;
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ServerGarbageCollection>true</ServerGarbageCollection>
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
<RetainVMGarbageCollection>true</RetainVMGarbageCollection>
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<SignAssembly>False</SignAssembly>
<Version>2.0.0</Version>
<ServerGarbageCollection>true</ServerGarbageCollection>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<LangVersion>9.0</LangVersion>
<TargetFrameworks>net9.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
2 changes: 1 addition & 1 deletion BitFaster.Caching.UnitTests.Std/DurationTests.cs
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ public void SinceEpoch()
// On .NET Standard, only windows uses TickCount64
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Duration.SinceEpoch().raw.Should().BeCloseTo(Duration.GetTickCount64(), 15);
Duration.SinceEpoch().raw.Should().BeCloseTo(Environment.TickCount64, 15);
}
else
{
Original file line number Diff line number Diff line change
@@ -91,8 +91,8 @@ public void WhenRemovedEventHandlerIsRegisteredItIsFired()
this.removedItems.First().Key.Should().Be(1);
}

// backcompat: remove conditional compile
#if NETCOREAPP3_0_OR_GREATER
// backcompat: remove conditional compile
#if NET
[Fact]
public void WhenUpdatedEventHandlerIsRegisteredItIsFired()
{
@@ -258,8 +258,8 @@ public async Task WhenFactoryThrowsEmptyKeyIsNotEnumerable()
cache.Keys.Count().Should().Be(0);
}

// backcompat: remove conditional compile
#if NETCOREAPP3_0_OR_GREATER
// backcompat: remove conditional compile
#if NET
[Fact]
public void WhenRemovedValueIsReturned()
{
4 changes: 2 additions & 2 deletions BitFaster.Caching.UnitTests/Atomic/AtomicFactoryCacheTests.cs
Original file line number Diff line number Diff line change
@@ -79,8 +79,8 @@ public void WhenRemovedEventHandlerIsRegisteredItIsFired()
this.removedItems.First().Key.Should().Be(1);
}

// backcompat: remove conditional compile
#if NETCOREAPP3_0_OR_GREATER
// backcompat: remove conditional compile
#if NET
[Fact]
public void WhenRemovedValueIsReturned()
{
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net48;netcoreapp3.1;net6.0</TargetFrameworks>
<LangVersion>9.0</LangVersion>
<TargetFrameworks>net48;net8.0;net9.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
Original file line number Diff line number Diff line change
@@ -100,7 +100,7 @@ public void WhenBufferEmptyDrainReturnsZero()
buffer.DrainTo(output).Should().Be(0);
}

#if NETCOREAPP3_0_OR_GREATER
#if NET
[Fact]
public void WhenBufferContainsItemsDrainArrayTakesItems()
{
4 changes: 2 additions & 2 deletions BitFaster.Caching.UnitTests/CacheEventProxyBaseTests.cs
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ public void WhenTwoRemovedEventHandlersAddedThenOneRemovedEventIsFired()
}

// backcompat: remove conditional compile
#if NETCOREAPP3_0_OR_GREATER
#if NET
[Fact]
public void WheUpdatedEventHandlerIsRegisteredItIsFired()
{
@@ -155,7 +155,7 @@ public void WhenUpdatedEventHandlerIsRegisteredAndProxyUsesDefaultUpdateTranslat

this.testCacheEvents.FireUpdated(1, new AtomicFactory<int, int>(2), new AtomicFactory<int, int>(3));

#if NETCOREAPP3_0_OR_GREATER
#if NET
this.updatedItems.First().Key.Should().Be(1);
#else
this.updatedItems.Should().BeEmpty();
2 changes: 1 addition & 1 deletion BitFaster.Caching.UnitTests/CacheEventsTests.cs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
namespace BitFaster.Caching.UnitTests
{
// backcompat: remove
#if NETCOREAPP3_1_OR_GREATER
#if NET
public class CacheEventsTests
{
[Fact]
2 changes: 1 addition & 1 deletion BitFaster.Caching.UnitTests/CacheMetricsTests.cs
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
namespace BitFaster.Caching.UnitTests
{
// backcompat: remove
#if NETCOREAPP3_1_OR_GREATER
#if NET
public class CacheMetricsTests
{
[Fact]
2 changes: 1 addition & 1 deletion BitFaster.Caching.UnitTests/CacheTests.cs
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ namespace BitFaster.Caching.UnitTests
public class CacheTests
{
// backcompat: remove conditional compile
#if NETCOREAPP3_0_OR_GREATER
#if NET
[Fact]
public void WhenCacheInterfaceDefaultGetOrAddFallback()
{
8 changes: 4 additions & 4 deletions BitFaster.Caching.UnitTests/DurationTests.cs
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ public DurationTests(ITestOutputHelper testOutputHelper)
[Fact]
public void SinceEpoch()
{
#if NETCOREAPP3_0_OR_GREATER
#if NET
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
// eps is 1/200 of a second
@@ -36,7 +36,7 @@ public void SinceEpoch()
#else
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Duration.SinceEpoch().raw.Should().BeCloseTo(Duration.GetTickCount64(), 15);
Duration.SinceEpoch().raw.Should().BeCloseTo(Environment.TickCount, 15);
}
else
{
@@ -50,7 +50,7 @@ public void SinceEpoch()
[Fact]
public void ToTimeSpan()
{
#if NETCOREAPP3_0_OR_GREATER
#if NET
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
new Duration(100).ToTimeSpan().Should().BeCloseTo(new TimeSpan(100), TimeSpan.FromMilliseconds(50));
@@ -75,7 +75,7 @@ public void ToTimeSpan()
[Fact]
public void FromTimeSpan()
{
#if NETCOREAPP3_0_OR_GREATER
#if NET
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
Duration.FromTimeSpan(TimeSpan.FromSeconds(1)).raw
12 changes: 2 additions & 10 deletions BitFaster.Caching.UnitTests/Intrinsics.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#if NETCOREAPP3_1_OR_GREATER
#if NET
using System.Runtime.Intrinsics.X86;
#endif
#if NET6_0_OR_GREATER
using System.Runtime.Intrinsics.Arm;
#endif

@@ -13,15 +11,9 @@ public static class Intrinsics
{
public static void SkipAvxIfNotSupported<I>()
{
#if NETCOREAPP3_1_OR_GREATER
#if NET6_0_OR_GREATER
#if NET
// when we are trying to test Avx2/Arm64, skip the test if it's not supported
Skip.If(typeof(I) == typeof(DetectIsa) && !(Avx2.IsSupported || AdvSimd.Arm64.IsSupported));
#else
// when we are trying to test Avx2, skip the test if it's not supported
Skip.If(typeof(I) == typeof(DetectIsa) && !Avx2.IsSupported);
#endif

#else
Skip.If(true);
#endif
6 changes: 3 additions & 3 deletions BitFaster.Caching.UnitTests/Lfu/ConcurrentLfuCoreTests.cs
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ public void WhenKeyIsRequestedItIsCreatedAndCached()
valueFactory.timesCalled.Should().Be(1);
result1.Should().Be(result2);
}
#if NETCOREAPP3_0_OR_GREATER
#if NET
[Fact]
public void WhenKeyIsRequestedWithArgItIsCreatedAndCached()
{
@@ -63,7 +63,7 @@ public async Task WhenKeyIsRequesteItIsCreatedAndCachedAsync()
result1.Should().Be(result2);
}

#if NETCOREAPP3_0_OR_GREATER
#if NET
[Fact]
public async Task WhenKeyIsRequestedWithArgItIsCreatedAndCachedAsync()
{
@@ -105,7 +105,7 @@ public void WhenKeyExistsTryRemoveRemovesItem()
lfu.TryGet(1, out _).Should().BeFalse();
}

#if NETCOREAPP3_0_OR_GREATER
#if NET
[Fact]
public void WhenKeyExistsTryRemoveReturnsValue()
{
Loading
Oops, something went wrong.
Loading
Oops, something went wrong.