From 29ca2e91f9f93bb5ec9c1b361f04e7fbee282cb3 Mon Sep 17 00:00:00 2001 From: Mark Cilia Vincenti Date: Sat, 25 Feb 2023 16:18:17 +0100 Subject: [PATCH 1/3] Add striped locking --- .../BenchmarkSimpleKeyLock.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/AsyncKeyLock.Benchmarks/BenchmarkSimpleKeyLock.cs b/src/AsyncKeyLock.Benchmarks/BenchmarkSimpleKeyLock.cs index bad10f7..88627c1 100644 --- a/src/AsyncKeyLock.Benchmarks/BenchmarkSimpleKeyLock.cs +++ b/src/AsyncKeyLock.Benchmarks/BenchmarkSimpleKeyLock.cs @@ -15,11 +15,13 @@ public void GlobalSetup() { o.PoolSize = NumberOfLocks; }); + _StripedAsyncKeyedLock = new AsyncKeyedLock.StripedAsyncKeyedLocker(NumberOfLocks); _ImageSharpWebLock = new SixLabors.ImageSharp.Web.Synchronization.AsyncKeyLock(); } private AsyncLock _AsyncKeyLock; private AsyncKeyedLock.AsyncKeyedLocker _AsyncKeyedLock; + private AsyncKeyedLock.StripedAsyncKeyedLocker _StripedAsyncKeyedLock; private SixLabors.ImageSharp.Web.Synchronization.AsyncKeyLock _ImageSharpWebLock; [Params(1_00, 1_000, 10_000)] @@ -48,6 +50,18 @@ public async Task AsyncKeyedLock() } } } + + [Benchmark] + public async Task StripedAsyncKeyedLock() + { + for (int i = 0; i < NumberOfLocks; i++) + { + using (await _StripedAsyncKeyedLock.LockAsync(string.Empty)) + { + + } + } + } [Benchmark] public async Task ImageSharpWeb() @@ -60,4 +74,4 @@ public async Task ImageSharpWeb() } } } -} \ No newline at end of file +} From e161f0428d5e3fb0145210cd574007bf522a053e Mon Sep 17 00:00:00 2001 From: Mark Cilia Vincenti Date: Sat, 25 Feb 2023 16:18:33 +0100 Subject: [PATCH 2/3] Update to AsyncKeyedLock 6.2.0 --- src/AsyncKeyLock.Benchmarks/AsyncKeyLock.Benchmarks.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AsyncKeyLock.Benchmarks/AsyncKeyLock.Benchmarks.csproj b/src/AsyncKeyLock.Benchmarks/AsyncKeyLock.Benchmarks.csproj index b27d49d..b89c307 100644 --- a/src/AsyncKeyLock.Benchmarks/AsyncKeyLock.Benchmarks.csproj +++ b/src/AsyncKeyLock.Benchmarks/AsyncKeyLock.Benchmarks.csproj @@ -8,7 +8,7 @@ - + From ad814d4e5c8f3dcb07a582ed6364575fd12f9296 Mon Sep 17 00:00:00 2001 From: Mark Cilia Vincenti Date: Mon, 10 Apr 2023 11:51:31 +0200 Subject: [PATCH 3/3] Update AsyncKeyLock.Benchmarks.csproj --- src/AsyncKeyLock.Benchmarks/AsyncKeyLock.Benchmarks.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AsyncKeyLock.Benchmarks/AsyncKeyLock.Benchmarks.csproj b/src/AsyncKeyLock.Benchmarks/AsyncKeyLock.Benchmarks.csproj index b89c307..eb91746 100644 --- a/src/AsyncKeyLock.Benchmarks/AsyncKeyLock.Benchmarks.csproj +++ b/src/AsyncKeyLock.Benchmarks/AsyncKeyLock.Benchmarks.csproj @@ -8,7 +8,7 @@ - +