Created
January 17, 2021 09:24
-
-
Save badamczewski/0837fab6d0301dec1f8309474d8615a3 to your computer and use it in GitHub Desktop.
IDIV vs SHR.cs
This file contains hidden or 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
| public class Bench6 | |
| { | |
| int div = 10; | |
| int by = 4; | |
| [Benchmark(Baseline = true)] | |
| public int Div() | |
| { | |
| var a = div; | |
| var b = by; | |
| int all = 0; | |
| all += a / b; | |
| all += a / b; | |
| all += a / b; | |
| all += a / b; | |
| all += a / b; | |
| all += a / b; | |
| all += a / b; | |
| all += a / b; | |
| return all; | |
| } | |
| [Benchmark] | |
| public int DivReduced() | |
| { | |
| var a = div; | |
| int all = 0; | |
| all += a / 4; | |
| all += a / 4; | |
| all += a / 4; | |
| all += a / 4; | |
| all += a / 4; | |
| all += a / 4; | |
| all += a / 4; | |
| all += a / 4; | |
| return all; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment