-
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.
The current test was based on the C++ test, but the overhead of the LeftShiftOverflowsMasks lookup is much higher on C#, especially on legacy .NET Framework. In particular, this new approach avoids range checks and theoretical exceptions.
- Loading branch information
1 parent
f70627d
commit 4cd1709
Showing
3 changed files
with
55 additions
and
11 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,17 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using Snappier.Internal; | ||
|
||
namespace Snappier.Benchmarks | ||
{ | ||
public class LeftShiftOverflows | ||
{ | ||
private byte value = 24; | ||
private int shift = 7; | ||
|
||
[Benchmark(Baseline = true)] | ||
public bool Current() | ||
{ | ||
return Helpers.LeftShiftOverflows(value, shift); | ||
} | ||
} | ||
} |
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