예제 #1
0
        public long Run(ThroughputSessionContext sessionContext)
        {
            var latch         = new ManualResetEvent(false);
            var expectedCount = _poller.Sequence.Value + _iterations;

            _pollRunnable.Reset(latch, expectedCount);
            var processorTask = _pollRunnable.Start();

            sessionContext.Start();

            var ringBuffer = _ringBuffer;

            for (var i = 0; i < _iterations; i++)
            {
                var next = ringBuffer.Next();
                ringBuffer[next].Value = i;
                ringBuffer.Publish(next);
            }

            latch.WaitOne();
            sessionContext.Stop();
            WaitForEventProcessorSequence(expectedCount);
            _pollRunnable.Halt();
            processorTask.Wait(2000);

            sessionContext.SetBatchData(_pollRunnable.BatchesProcessedCount.Value, _iterations);

            PerfTestUtil.FailIfNot(_expectedResult, _pollRunnable.Value, $"Poll runnable should have processed {_expectedResult} but was {_pollRunnable.Value}");

            return(_iterations);
        }
예제 #2
0
        public long Run(Stopwatch stopwatch)
        {
            var latch         = new ManualResetEvent(false);
            var expectedCount = _poller.Sequence.Value + _iterations;

            _pollRunnable.Reset(latch, expectedCount);
            var processorTask = _executor.Execute(_pollRunnable.Run);

            stopwatch.Start();

            var rb = _ringBuffer;

            for (var i = 0; i < _iterations; i++)
            {
                var next = rb.Next();
                rb[next].Value = i;
                rb.Publish(next);
            }

            latch.WaitOne();
            stopwatch.Stop();
            WaitForEventProcessorSequence(expectedCount);
            _pollRunnable.Halt();
            processorTask.Wait(2000);

            PerfTestUtil.FailIfNot(_expectedResult, _pollRunnable.Value, $"Poll runnable should have processed {_expectedResult} but was {_pollRunnable.Value}");

            return(_iterations);
        }