Exemplo n.º 1
0
        public long Run(ThroughputSessionContext sessionContext)
        {
            var signal = new ManualResetEvent(false);

            _fizzBuzzQueueProcessor.Reset(signal);
            var tasks = new Task[_eventProcessorCount];

            tasks[0] = _executor.Execute(_fizzQueueProcessor.Run);
            tasks[1] = _executor.Execute(_buzzQueueProcessor.Run);
            tasks[2] = _executor.Execute(_fizzBuzzQueueProcessor.Run);

            sessionContext.Start();

            for (var i = 0; i < _iterations; i++)
            {
                _fizzInputQueue.Enqueue(i);
                _buzzInputQueue.Enqueue(i);
            }

            signal.WaitOne();
            sessionContext.Stop();

            _fizzQueueProcessor.Halt();
            _buzzQueueProcessor.Halt();
            _fizzBuzzQueueProcessor.Halt();

            Task.WaitAll(tasks);

            PerfTestUtil.FailIf(_expectedResult, 0);

            return(_iterations);
        }
Exemplo n.º 2
0
        public long Run(Stopwatch stopwatch)
        {
            var signal        = new ManualResetEvent(false);
            var expectedCount = _batchEventProcessor.Sequence.Value + _iterations;

            _handler.Reset(signal, _iterations);
            var processorTask = _executor.Execute(_batchEventProcessor.Run);

            stopwatch.Start();

            var rb = _ringBuffer;

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

            signal.WaitOne();
            stopwatch.Stop();
            WaitForEventProcessorSequence(expectedCount);
            _batchEventProcessor.Halt();
            processorTask.Wait(2000);

            PerfTestUtil.FailIf(0, _handler.Value, "Handler has not processed any event");

            return(_iterations * _arraySize);
        }
Exemplo n.º 3
0
        public long Run(ThroughputSessionContext sessionContext)
        {
            var latch = new ManualResetEvent(false);

            _queueProcessor.Reset(latch);
            var future = Task.Run(() => _queueProcessor.Run());

            sessionContext.Start();

            for (long i = 0; i < _iterations; i++)
            {
                _blockingQueue.Enqueue(3L);
            }

            latch.WaitOne();
            sessionContext.Stop();
            _queueProcessor.Halt();
            future.Wait();

            PerfTestUtil.FailIf(_expectedResult, 0);

            return(_iterations);
        }
Exemplo n.º 4
0
        public long Run(Stopwatch stopwatch)
        {
            var signal = new ManualResetEvent(false);

            _stepThreeQueueProcessor.Reset(signal);

            var tasks = new Task[_eventProcessorCount];

            tasks[0] = _executor.Execute(_stepOneQueueProcessor.Run);
            tasks[1] = _executor.Execute(_stepTwoQueueProcessor.Run);
            tasks[2] = _executor.Execute(_stepThreeQueueProcessor.Run);

            stopwatch.Start();

            long operandTwo = _operandTwoInitialValue;

            for (long i = 0; i < _iterations; i++)
            {
                long[] values = new long[2];
                values[0] = i;
                values[1] = operandTwo--;
                _stepOneQueue.Enqueue(values);
            }

            signal.WaitOne();
            stopwatch.Stop();

            _stepOneQueueProcessor.Halt();
            _stepTwoQueueProcessor.Halt();
            _stepThreeQueueProcessor.Halt();

            Task.WaitAll(tasks);

            PerfTestUtil.FailIf(_expectedResult, 0);

            return(_iterations);
        }
Exemplo n.º 5
0
        public long Run(ThroughputSessionContext sessionContext)
        {
            var signal        = new ManualResetEvent(false);
            var expectedCount = _batchEventProcessor.Sequence.Value + _iterations;

            _handler.Reset(signal, _iterations);
            var processorTask = _batchEventProcessor.Start();

            _batchEventProcessor.WaitUntilStarted(TimeSpan.FromSeconds(5));

            sessionContext.Start();

            var ringBuffer = _ringBuffer;

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

            signal.WaitOne();
            sessionContext.Stop();
            WaitForEventProcessorSequence(expectedCount);
            _batchEventProcessor.Halt();
            processorTask.Wait(2000);

            sessionContext.SetBatchData(_handler.BatchesProcessed, _iterations);

            PerfTestUtil.FailIf(0, _handler.Value, "Handler has not processed any event");

            return(_iterations * _arraySize);
        }