-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add observability support (activities & meters) * Add OpenTelemetry instrumentation project * Added IFusionCacheMemoryLocker and related impl + marked IFusionCacheReactor and friends as obsolete * Add builder tests for memory locker * Add NullMemoryLocker * Add ChaosMemoryLocker + minor * Better [Obsolete] usage * Better auto-recovery TryDeleteItem() * Better tests * Add OpenTelemetry scenario in the Playground * Add Scratchpad scenario in the playground * Minor updates to GitHub actions * Update package refs * Update SourceLink package * Docs changes
- Loading branch information
1 parent
d77f6f4
commit f70856c
Showing
115 changed files
with
3,037 additions
and
1,394 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
benchmarks/ZiggyCreatures.FusionCache.Benchmarks/HappyPathBenchmark.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Columns; | ||
using BenchmarkDotNet.Configs; | ||
using BenchmarkDotNet.Jobs; | ||
using FastCache; | ||
using LazyCache; | ||
using Microsoft.Extensions.Caching.Memory; | ||
|
||
namespace ZiggyCreatures.Caching.Fusion.Benchmarks | ||
{ | ||
[RankColumn] | ||
[MemoryDiagnoser] | ||
[Config(typeof(Config))] | ||
[ShortRunJob(RuntimeMoniker.Net60)] | ||
[ShortRunJob(RuntimeMoniker.Net80)] | ||
[Orderer(BenchmarkDotNet.Order.SummaryOrderPolicy.FastestToSlowest)] | ||
public class HappyPathBenchmark | ||
{ | ||
private class Config : ManualConfig | ||
{ | ||
public Config() | ||
{ | ||
AddColumn( | ||
StatisticColumn.P95 | ||
); | ||
} | ||
} | ||
|
||
const string Key = "test key"; | ||
const string Value = "test value"; | ||
|
||
readonly FusionCache FusionCache = new(new FusionCacheOptions()); | ||
readonly MemoryCache MemoryCache = new(new MemoryCacheOptions()); | ||
readonly CachingService LazyCache = new(); | ||
|
||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
FusionCache.Set(Key, Value); | ||
MemoryCache.Set(Key, Value); | ||
LazyCache.Add(Key, Value); | ||
Cached<string>.Save(Key, Value, TimeSpan.FromDays(1)); | ||
} | ||
|
||
public class HappyPathReads : HappyPathBenchmark | ||
{ | ||
[Benchmark(Baseline = true)] | ||
public string? GetFusionCache() | ||
{ | ||
return FusionCache.TryGet<string?>(Key) | ||
.GetValueOrDefault(null); | ||
} | ||
|
||
[Benchmark] | ||
public string? GetMemoryCache() | ||
{ | ||
return MemoryCache.TryGetValue<string?>(Key, out var value) | ||
? value | ||
: Unreachable(); | ||
} | ||
|
||
[Benchmark] | ||
public string? GetLazyCache() | ||
{ | ||
return LazyCache.TryGetValue<string?>(Key, out var value) | ||
? value | ||
: Unreachable(); | ||
} | ||
|
||
[Benchmark] | ||
public string? GetFastCache() | ||
{ | ||
return Cached<string?>.TryGet(Key, out var value) | ||
? value | ||
: Unreachable(); | ||
} | ||
} | ||
|
||
public class HappyPathWrites : HappyPathBenchmark | ||
{ | ||
[Benchmark(Baseline = true)] | ||
public void SetFusionCache() => FusionCache.Set(Key, Value); | ||
|
||
[Benchmark] | ||
public void SetMemoryCache() => MemoryCache.Set(Key, Value); | ||
|
||
[Benchmark] | ||
public void SetLazyCache() => LazyCache.Add(Key, Value); | ||
|
||
[Benchmark] | ||
public void SetFastCache() => Cached<string>.Save(Key, Value, TimeSpan.FromDays(1)); | ||
} | ||
|
||
[DoesNotReturn] | ||
static string Unreachable() => throw new Exception("Unreachable code"); | ||
} | ||
} |
Oops, something went wrong.