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
16 changes: 15 additions & 1 deletion src/AsyncKeyLock.Benchmarks/BenchmarkSimpleKeyLock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ public void GlobalSetup()
{
o.PoolSize = NumberOfLocks;
});
_StripedAsyncKeyedLock = new AsyncKeyedLock.StripedAsyncKeyedLocker<string>(NumberOfLocks);
_ImageSharpWebLock = new SixLabors.ImageSharp.Web.Synchronization.AsyncKeyLock<string>();
}

private AsyncLock<string> _AsyncKeyLock;
private AsyncKeyedLock.AsyncKeyedLocker<string> _AsyncKeyedLock;
private AsyncKeyedLock.StripedAsyncKeyedLocker<string> _StripedAsyncKeyedLock;
private SixLabors.ImageSharp.Web.Synchronization.AsyncKeyLock<string> _ImageSharpWebLock;

[Params(1_00, 1_000, 10_000)]
Expand Down Expand Up @@ -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()
Expand All @@ -60,4 +74,4 @@ public async Task ImageSharpWeb()
}
}
}
}
}