Skip to content

Instantly share code, notes, and snippets.

@badamczewski
Last active July 27, 2021 12:51
Show Gist options
  • Save badamczewski/ec4fd63661276e2a375bcd2389692936 to your computer and use it in GitHub Desktop.
Save badamczewski/ec4fd63661276e2a375bcd2389692936 to your computer and use it in GitHub Desktop.
public class Bench92
{
[Benchmark(Baseline = true)]
[MethodImpl(MethodImplOptions.NoInlining)]
[Arguments(0)]
public int A(int x)
{
try { _ = 1; } catch { }
for (int i = 0; i < 10000; i++) {
x++; x++; x++; x++;
}
return x;
}
[Benchmark()]
[MethodImpl(MethodImplOptions.NoInlining)]
[Arguments(0)]
public int B(int x)
{
try { _ = 1; } catch { }
var y = x;
for (int i = 0; i < 10000; i++) {
y++; y++; y++; y++;
}
return y;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment