Closed jnyrup closed 4 years ago
Method | Mean | Error | StdDev | Ratio | Gen 0 | Gen 1 | Gen 2 | Allocated |
---|---|---|---|---|---|---|---|---|
DotNetMemoryCache_GetOrAddAsync | 372.7 ns | 11.15 ns | 0.61 ns | 1.00 | 0.0334 | - | - | 280 B |
LazyCache_GetOrAddAsync_Proposed | 516.4 ns | 16.93 ns | 0.93 ns | 1.39 | 0.0448 | - | - | 376 B |
LazyCache_GetOrAddAsync | 584.4 ns | 5.17 ns | 0.28 ns | 1.57 | 0.0534 | - | - | 448 B |
Here's some numbers with the proposed change as well. Good find!
@svengeance Thanks for providing the numbers that confirms the change.
If you're a heap allocation hunter, you might be interested in ClrHeapAllocationAnalyzer
As
GetOrAddAsync
only calls the otherGetOrAddAsync
method with an extranull
parameter it should not be necessary toawait
the call. This also makes up for the a missingConfigureAwait(false)
introduced in https://github.com/alastairtree/LazyCache/commit/218bd2352b1217c9bacdf35566c19ebb3c85c7fa#diff-4a28b127c5a26901c14d4513be185990R165