public long Run(ThroughputSessionContext sessionContext)
    {
        var latch = new ManualResetEvent(false);

        _stepThreeFunctionHandler.Reset(latch, _stepThreeEventProcessor.Sequence.Value + _iterations);

        var processorTask1 = _stepOneEventProcessor.Start();
        var processorTask2 = _stepTwoEventProcessor.Start();
        var processorTask3 = _stepThreeEventProcessor.Start();

        _stepOneEventProcessor.WaitUntilStarted(TimeSpan.FromSeconds(5));
        _stepTwoEventProcessor.WaitUntilStarted(TimeSpan.FromSeconds(5));
        _stepThreeEventProcessor.WaitUntilStarted(TimeSpan.FromSeconds(5));

        sessionContext.Start();

        var ringBuffer = _ringBuffer;

        var operandTwo = _operandTwoInitialValue;

        for (long i = 0; i < _iterations; i++)
        {
            var sequence = ringBuffer.Next();
            var @event   =
                ringBuffer[sequence];
            @event.OperandOne = i;
            @event.OperandTwo = operandTwo--;
            ringBuffer.Publish(sequence);
        }

        latch.WaitOne();
        sessionContext.Stop();

        _stepOneEventProcessor.Halt();
        _stepTwoEventProcessor.Halt();
        _stepThreeEventProcessor.Halt();
        Task.WaitAll(processorTask1, processorTask2, processorTask3);

        PerfTestUtil.FailIfNot(_expectedResult, _stepThreeFunctionHandler.StepThreeCounter);

        return(_iterations);
    }
        public long Run(Stopwatch stopwatch)
        {
            var latch = new ManualResetEvent(false);

            _stepThreeFunctionHandler.Reset(latch, _stepThreeBatchProcessor.Sequence.Value + _iterations);

            var processorTask1 = _executor.Submit(_stepOneBatchProcessor);
            var processorTask2 = _executor.Submit(_stepTwoBatchProcessor);
            var processorTask3 = _executor.Submit(_stepThreeBatchProcessor);

            stopwatch.Start();

            var operandTwo = _operandTwoInitialValue;

            for (long i = 0; i < _iterations; i++)
            {
                var sequence = _ringBuffer.Next();
                var @event   =
                    _ringBuffer[sequence];
                @event.OperandOne = i;
                @event.OperandTwo = operandTwo--;
                _ringBuffer.Publish(sequence);
            }

            latch.WaitOne();
            stopwatch.Stop();

            _stepOneBatchProcessor.Halt();
            _stepTwoBatchProcessor.Halt();
            _stepThreeBatchProcessor.Halt();
            Task.WaitAll(processorTask1, processorTask2, processorTask3);

            PerfTestUtil.FailIfNot(_expectedResult, _stepThreeFunctionHandler.StepThreeCounter);

            return(_iterations);
        }