Benchmark results and TODOs added / updated
This commit is contained in:
1 parent
507b9c91f4
commit
f9e548279c
31 files changed
+581
-364
No files matched your search
@@ -8,22 +8,49 @@ namespace EvenPerfectBitScanner.Benchmarks;
|
||||
[MemoryDiagnoser]
|
||||
public class Mod5UIntBenchmarks
|
||||
{
|
||||
[Params(3UL, 5UL, 6UL, 8UL, 10UL, 11UL, 32UL, 64UL, 128UL, 256UL, 2_047UL, 8_191UL, 65_535UL, 131_071UL, 2_147_483_647UL, uint.MaxValue - 1_024UL, uint.MaxValue - 511UL, uint.MaxValue - 255UL, uint.MaxValue - 127UL, uint.MaxValue - 63UL, uint.MaxValue - 31UL, uint.MaxValue - 17UL, uint.MaxValue)]
|
||||
[Params(
|
||||
3U,
|
||||
5U,
|
||||
6U,
|
||||
8U,
|
||||
10U,
|
||||
11U,
|
||||
32U,
|
||||
64U,
|
||||
128U,
|
||||
256U,
|
||||
2047U,
|
||||
8191U,
|
||||
65535U,
|
||||
131071U,
|
||||
2147483647U,
|
||||
uint.MaxValue - 1024U,
|
||||
uint.MaxValue - 511U,
|
||||
uint.MaxValue - 255U,
|
||||
uint.MaxValue - 127U,
|
||||
uint.MaxValue - 63U,
|
||||
uint.MaxValue - 31U,
|
||||
uint.MaxValue - 17U,
|
||||
uint.MaxValue)]
|
||||
public uint Value { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// `% 5` baseline; times hovered around 0.03 ns with the expected zero-measurement noise (0.0296 ns at value 5, 0.0671 ns at 6,
|
||||
/// 0.0326 ns at 8, 0.0289 ns at 10, 0.1236 ns at 11, dropping back to ~0.03 ns for large values).
|
||||
/// </summary>
|
||||
[Benchmark(Baseline = true)]
|
||||
public uint ModuloOperator()
|
||||
{
|
||||
return Value % 5U;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mixed results. Sometimes it's faster, in higher ranges, sometimes it's slower.
|
||||
/// </summary>
|
||||
[Benchmark]
|
||||
/// <summary>
|
||||
/// Extension helper; typically within 0.03-0.04 ns (0.0349 ns at value 3, 0.0294 ns at 8, 0.0305 ns at 65535, 0.0270 ns at 131071,
|
||||
/// 0.0327 ns at 2147483647) though the dataset contains an outlier at value 11 (0.0315 ns) and value 64 (0.0356 ns).
|
||||
/// </summary>
|
||||
[Benchmark]
|
||||
public uint ExtensionMethod()
|
||||
{
|
||||
return Value.Mod5();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user