Created
July 27, 2021 13:41
-
-
Save badamczewski/03a53c07dfbe013aa8b8ff99f49a208c to your computer and use it in GitHub Desktop.
Revisions
-
badamczewski created this gist
Jul 27, 2021 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ public class Bench92 { public int[] _x = null; [GlobalSetup] public void Setup() { _x = new int[10000]; } [Benchmark(Baseline = true)] [MethodImpl(MethodImplOptions.NoInlining)] [Arguments(0)] public int A(int z) { var x = _x; try { _ = 1; } catch { } for (int i = 0; i < x.Length; i++) { x[i] += i + z; z += x[i]; } return z; } [Benchmark()] [MethodImpl(MethodImplOptions.NoInlining)] [Arguments(0)] public int B(int z) { var x = _x; try { _ = 1; } catch { } var y = x; var zz = z; for (int i = 0; i < y.Length; i++) { y[i] += i + zz; zz += y[i]; } return zz; } }