Benchmarks
When getting a result that is already in cache, the result is provided at 200ns and with zero heap allocation.
When constructing a new result, there is total overhead of 400ns for one handler, and very low heap allocation.
When using async call model for getting a cached result is 450ns.
When using async call model for creating a new result with one handlers is 1350ns
On .Net 6.
Method | Mean | Error | StdDev | Gen 0 | Allocated |
---|---|---|---|---|---|
GetWithCache | 228.7 ns | 4.45 ns | 6.67 ns | - | - |
GetAsyncWithCache | 397.1 ns | 6.03 ns | 5.64 ns | 0.0286 | 240 B |
GetWithoutCache | 444.8 ns | 8.84 ns | 11.81 ns | 0.0296 | 248 B |
GetAsyncWithoutCache | 1,362.1 ns | 14.12 ns | 16.81 ns | 0.1125 | 943 B |
On .Net 7 (preview)
Method | Mean | Error | StdDev | Gen 0 | Allocated |
---|---|---|---|---|---|
GetWithCache | 215.2 ns | 2.73 ns | 2.42 ns | - | - |
GetAsyncWithCache | 400.8 ns | 3.12 ns | 2.92 ns | 0.0286 | 240 B |
GetWithoutCache | 409.7 ns | 2.11 ns | 1.65 ns | 0.0257 | 216 B |
GetAsyncWithoutCache | 4,485.0 ns | 40.01 ns | 37.43 ns | 0.1755 | 1463 B |
For some reason Tasks have become slower on .NET 7.