Skip to content

Instantly share code, notes, and snippets.

@Zhentar
Created April 19, 2019 03:01
Show Gist options
  • Select an option

  • Save Zhentar/deb1afb9bc30ed2a82583a348729dc9f to your computer and use it in GitHub Desktop.

Select an option

Save Zhentar/deb1afb9bc30ed2a82583a348729dc9f to your computer and use it in GitHub Desktop.

Revisions

  1. Zhentar created this gist Apr 19, 2019.
    67 changes: 67 additions & 0 deletions OverheadExample.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,67 @@
    using BenchmarkDotNet.Attributes;
    using BenchmarkDotNet.Running;

    namespace BDNTest
    {
    public class Program
    {
    public static void Main() => BenchmarkRunner.Run<OverheadTests>();
    }

    [SimpleJob]
    public class OverheadTests
    {
    private int _field;

    [Benchmark]
    public void OneIncrement()
    {
    _field++;
    }

    [Benchmark]
    public void TwoIncrement()
    {
    _field++;
    _field++;
    }

    [Benchmark]
    public void ThreeIncrement()
    {
    _field++;
    _field++;
    _field++;
    }

    [Benchmark]
    public void FourIncrement()
    {
    _field++;
    _field++;
    _field++;
    _field++;
    }

    [Benchmark]
    public void FiveIncrement()
    {
    _field++;
    _field++;
    _field++;
    _field++;
    _field++;
    }

    [Benchmark]
    public void SixIncrement()
    {
    _field++;
    _field++;
    _field++;
    _field++;
    _field++;
    _field++;
    }
    }
    }