-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Marked Swap() with AggressiveInlining, and used this in SwapIfGreat…
…er(). Together these two changes give a 15% performance improvement in the synthetic benchmark. - Added IntroSortKVWBenchmarks.
- Loading branch information
Showing
3 changed files
with
58 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using Redzen.Random; | ||
using Redzen.Sorting; | ||
|
||
namespace Redzen.Benchmarks | ||
{ | ||
[InvocationCount(1000)] | ||
[MinWarmupCount(6, forceAutoWarmup: true)] // when InvocationCount is set, BDN does not run Pilot Stage, so to get the code promoted to Tier 1 before Actual Workload, we enforce more Warmups | ||
public class IntroSortKVWBenchmarks | ||
{ | ||
[Params(50_000)] | ||
public int Length; | ||
|
||
int[] _keys; | ||
int[] _values; | ||
int[] _values2; | ||
IRandomSource _rng = RandomDefaults.CreateRandomSource(123); | ||
|
||
[GlobalSetup] | ||
public void GlobalSetup() | ||
{ | ||
_keys = new int[Length]; | ||
_values = new int[Length]; | ||
_values2 = new int[Length]; | ||
|
||
for(int i=0; i < _keys.Length; i++) | ||
{ | ||
_keys[i] = _rng.Next(); | ||
_values[i] = _keys[i]; | ||
_values2[i] = _keys[i]; | ||
} | ||
} | ||
|
||
[IterationSetup] | ||
public void IterationSetup() | ||
{ | ||
SortUtils.Shuffle<int>(_keys, _rng); | ||
} | ||
|
||
[Benchmark] | ||
public void Sort() | ||
{ | ||
IntroSort<int,int,int>.Sort(_keys, _values, _values2); | ||
} | ||
} | ||
} |
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