public long Run(ThroughputSessionContext sessionContext) { long expectedCount = _eventProcessor.Sequence.Value + _iterations; _eventHandler.Reset(expectedCount); var processorTask = _eventProcessor.Start(); _eventProcessor.WaitUntilStarted(TimeSpan.FromSeconds(5)); sessionContext.Start(); var ringBuffer = _ringBuffer; for (long i = 0; i < _iterations; i++) { var s = ringBuffer.Next(); ringBuffer[s].Value = i; ringBuffer.Publish(s); } _eventHandler.WaitForSequence(); sessionContext.Stop(); PerfTestUtil.WaitForEventProcessorSequence(expectedCount, _eventProcessor); _eventProcessor.Halt(); processorTask.Wait(2000); sessionContext.SetBatchData(_eventHandler.BatchesProcessed, _iterations); PerfTestUtil.FailIfNot(_expectedResult, _eventHandler.Value, $"Handler should have processed {_expectedResult} events, but was: {_eventHandler.Value}"); return(_iterations); }
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(ThroughputSessionContext sessionContext) { var latch = new ManualResetEvent(false); _fizzBuzzHandler.Reset(latch, _eventProcessorFizzBuzz.Sequence.Value + _iterations); var processorTask1 = _eventProcessorFizz.StartLongRunning(); var processorTask2 = _eventProcessorBuzz.StartLongRunning(); var processorTask3 = _eventProcessorFizzBuzz.StartLongRunning(); _eventProcessorFizz.WaitUntilStarted(TimeSpan.FromSeconds(5)); _eventProcessorBuzz.WaitUntilStarted(TimeSpan.FromSeconds(5)); _eventProcessorFizzBuzz.WaitUntilStarted(TimeSpan.FromSeconds(5)); sessionContext.Start(); var ringBuffer = _ringBuffer; for (long i = 0; i < _iterations; i++) { var sequence = ringBuffer.Next(); ringBuffer[sequence].Value = i; ringBuffer.Publish(sequence); } latch.WaitOne(); sessionContext.Stop(); _eventProcessorFizz.Halt(); _eventProcessorBuzz.Halt(); _eventProcessorFizzBuzz.Halt(); Task.WaitAll(processorTask1, processorTask2, processorTask3); PerfTestUtil.FailIfNot(_expectedResult, _fizzBuzzHandler.FizzBuzzCounter); return(_iterations); }
public long Run(ThroughputSessionContext sessionContext) { var signal = new ManualResetEvent(false); var expectedCount = _eventProcessor.Sequence.Value + _iterations; _handler.Reset(signal, _iterations); var processorTask = _eventProcessor.Start(); _eventProcessor.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); _eventProcessor.Halt(); processorTask.Wait(2000); sessionContext.SetBatchData(_handler.BatchesProcessed, _iterations); PerfTestUtil.FailIf(0, _handler.Value, "Handler has not processed any event"); return(_iterations * _arraySize); }
public long Run(ThroughputSessionContext sessionContext) { var expectedCount = _eventProcessor.Sequence.Value + _iterations * _batchSize; _handler.Reset(expectedCount); var processorTask = _eventProcessor.Start(); _eventProcessor.WaitUntilStarted(TimeSpan.FromSeconds(5)); sessionContext.Start(); var ringBuffer = _ringBuffer; for (var i = 0; i < _iterations; i++) { var hi = ringBuffer.Next(_batchSize); var lo = hi - (_batchSize - 1); for (var l = lo; l <= hi; l++) { ringBuffer[l].Value = (i); } ringBuffer.Publish(lo, hi); } _handler.WaitForSequence(); sessionContext.Stop(); PerfTestUtil.WaitForEventProcessorSequence(expectedCount, _eventProcessor); _eventProcessor.Halt(); processorTask.Wait(2000); sessionContext.SetBatchData(_handler.BatchesProcessed, _iterations * _batchSize); PerfTestUtil.FailIfNot(_expectedResult, _handler.Value, $"Handler should have processed {_expectedResult} events, but was: {_handler.Value}"); return(_batchSize * _iterations); }
public void Halt() { _processor.Halt(); }
public void Halt() { eventprocessor.Halt(); }