-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Codegen fixes for CachedRange IEnumerable overload
- Sacrifice ordering by expiration in quicklist when inserting from IEnumerable to reduce loop body size - Add benchmarks to track actual CachedRange perf - Add PolySharp to work towards removing hand-rolled polyfills for older targets
- Loading branch information
1 parent
799f2d3
commit 512bbb6
Showing
7 changed files
with
800 additions
and
769 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
using BenchmarkDotNet.Running; | ||
|
||
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(); | ||
BenchmarkSwitcher | ||
.FromAssembly(typeof(Program).Assembly) | ||
.Run(); |
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,43 @@ | ||
using FastCache.Collections; | ||
|
||
namespace FastCache.Benchmarks; | ||
|
||
[ShortRunJob, MemoryDiagnoser] | ||
// [DisassemblyDiagnoser(maxDepth: 3, exportCombinedDisassemblyReport: true)] | ||
public class RangeWritesOverloads | ||
{ | ||
private (int, string)[] _array = Array.Empty<(int, string)>(); | ||
|
||
private List<(int, string)> _list = new(); | ||
|
||
private (int[], string[]) _kvpArrays = (Array.Empty<int>(), Array.Empty<string>()); | ||
|
||
[Params(1000, 1_000_000)] | ||
public int Length; | ||
|
||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
var seed = (0..Length).AsEnumerable().Select(key => (key, $"{key}")).ToArray(); | ||
|
||
_array = seed; | ||
_list = seed.ToList(); | ||
_kvpArrays = ( | ||
seed.Select(kvp => kvp.key).ToArray(), | ||
seed.Select(kvp => kvp.Item2).ToArray()); | ||
} | ||
|
||
[Benchmark(Baseline = true)] | ||
public void SaveArray() => CachedRange<string>.Save(_array, TimeSpan.MaxValue); | ||
|
||
[Benchmark] | ||
public void SaveList() => CachedRange<string>.Save(_list, TimeSpan.MaxValue); | ||
|
||
[Benchmark] | ||
public void SaveSplitArr() => | ||
CachedRange<string>.Save(_kvpArrays.Item1, _kvpArrays.Item2, TimeSpan.MaxValue); | ||
|
||
[Benchmark] | ||
public void SaveEnumerable() => | ||
CachedRange<string>.Save(_array.Select(kvp => kvp), TimeSpan.MaxValue); | ||
} |
Oops, something went wrong.