| 27 | } |
| 28 | |
| 29 | std::int64_t OneToOneSequencedThroughputTest::run(Stopwatch& stopwatch) |
| 30 | { |
| 31 | m_taskScheduler->start(requiredProcessorCount()); |
| 32 | TestTools::ScopeExitFunctor atScopeExit([this] { m_taskScheduler->stop(); }); |
| 33 | |
| 34 | auto expectedCount = m_batchEventProcessor->sequence()->value() + m_iterations; |
| 35 | |
| 36 | m_latch->reset(); |
| 37 | m_eventHandler->reset(m_latch, expectedCount); |
| 38 | |
| 39 | auto processorTask = m_executor->execute([this] { m_batchEventProcessor->run(); }); |
| 40 | stopwatch.start(); |
| 41 | |
| 42 | auto&& rb = *m_ringBuffer; |
| 43 | |
| 44 | for (auto i = 0; i < m_iterations; ++i) |
| 45 | { |
| 46 | auto sequence = rb.next(); |
| 47 | rb[sequence].value = i; |
| 48 | rb.publish(sequence); |
| 49 | } |
| 50 | |
| 51 | m_latch->waitOne(); |
| 52 | stopwatch.stop(); |
| 53 | PerfTestUtil::waitForEventProcessorSequence(expectedCount, m_batchEventProcessor); |
| 54 | m_batchEventProcessor->halt(); |
| 55 | processorTask.wait_for(std::chrono::seconds(10)); |
| 56 | |
| 57 | PerfTestUtil::failIfNot(m_expectedResult, m_eventHandler->value(), |
| 58 | "Handler should have processed " + std::to_string(m_expectedResult) + " events, but was: " + std::to_string(m_eventHandler->value())); |
| 59 | |
| 60 | return m_iterations; |
| 61 | } |
| 62 | |
| 63 | std::int32_t OneToOneSequencedThroughputTest::requiredProcessorCount() const |
| 64 | { |
nothing calls this directly
no test coverage detected