Created
January 17, 2021 09:17
-
-
Save badamczewski/0a4387814626ed1bd7c19984314491e9 to your computer and use it in GitHub Desktop.
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 Bench | |
| { | |
| int mul = 10; | |
| int by = 4; | |
| [Benchmark(Baseline = true)] | |
| public int Mul() | |
| { | |
| var a = mul; | |
| 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 MulReduced() | |
| { | |
| var a = mul; | |
| 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