Table of Contents

Sample: IntroStopOnFirstError

BenchmarkDotNet can be configured to stop on first error. You just have to add StopOnFirstError attribute to your class or use --stopOnFirstError command line argument.

Source code

using System;
using BenchmarkDotNet.Attributes;

namespace BenchmarkDotNet.Samples
{
    [StopOnFirstError]
    public class IntroStopOnFirstError
    {
        [Benchmark(Baseline = true)]
        public int FirstMethod() => throw new Exception("Example exception.");

        [Benchmark]
        public int SecondMethod() => 1;
    }
}