public override StoppingResult Evaluate(IReadOnlyList <Measurement> measurements)
        {
            int n = measurements.Count;

            if (n >= maxIterationCount)
            {
                return(StoppingResult.CreateFinished(maxIterationMessage));
            }
            if (n < minIterationCount)
            {
                return(StoppingResult.NotFinished);
            }

            int direction        = -1; // The default "pre-state" is "decrease mode"
            int fluctuationCount = 0;

            for (int i = 1; i < n; i++)
            {
                int nextDirection = Math.Sign(measurements[i].Nanoseconds - measurements[i - 1].Nanoseconds);
                if (nextDirection != direction || nextDirection == 0)
                {
                    direction = nextDirection;
                    fluctuationCount++;
                }
            }

            return(fluctuationCount >= minFluctuationCount
                ? StoppingResult.CreateFinished(minFluctuationMessage)
                : StoppingResult.NotFinished);
        }
 public override StoppingResult Evaluate(IReadOnlyList <Measurement> measurements)
 => measurements.Count >= MaxIterationCount
         ? StoppingResult.CreateFinished(message)
         : StoppingResult.NotFinished;