protected override long RunDisruptorPass()
        {
            CountdownEvent latch         = new CountdownEvent(1);
            long           expectedCount = poller.GetSequence().Value + ITERATIONS;

            pollRunnable.reset(latch, expectedCount);
            Task.Factory.StartNew(() => pollRunnable.Run());
            Stopwatch watch = Stopwatch.StartNew();

            RingBuffer <ValueEvent> rb = ringBuffer;

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

            latch.Wait();
            long opsPerSecond = (ITERATIONS * 1000L) / (watch.ElapsedMilliseconds);

            waitForEventProcessorSequence(expectedCount);
            pollRunnable.Halt();

            PerfTestUtil.failIfNot(expectedResult, pollRunnable.getValue());

            return(opsPerSecond);
        }
Beispiel #2
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);
        }
Beispiel #3
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);
        }