| 48 | } |
| 49 | |
| 50 | std::int64_t OneToThreeSequencedThroughputTest::run(Stopwatch& stopwatch) |
| 51 | { |
| 52 | m_taskScheduler->start(requiredProcessorCount()); |
| 53 | TestTools::ScopeExitFunctor atScopeExit([this] { m_taskScheduler->stop(); }); |
| 54 | |
| 55 | auto latch = std::make_shared< boost::barrier >(m_numEventProcessors + 1); |
| 56 | |
| 57 | std::vector< std::future< void > > processorTasks; |
| 58 | for (auto i = 0; i < m_numEventProcessors; ++i) |
| 59 | { |
| 60 | m_handlers[i]->reset(latch, m_batchEventProcessors[i]->sequence()->value() + m_iterations); |
| 61 | processorTasks.push_back(m_executor->execute([this, i] { m_batchEventProcessors[i]->run(); })); |
| 62 | } |
| 63 | |
| 64 | auto& rb = *m_ringBuffer; |
| 65 | |
| 66 | stopwatch.start(); |
| 67 | |
| 68 | for (std::int64_t i = 0; i < m_iterations; ++i) |
| 69 | { |
| 70 | auto sequence = rb.next(); |
| 71 | rb[sequence].value = i; |
| 72 | rb.publish(sequence); |
| 73 | } |
| 74 | |
| 75 | latch->wait(); |
| 76 | stopwatch.stop(); |
| 77 | |
| 78 | for (auto i = 0; i < m_numEventProcessors; ++i) |
| 79 | { |
| 80 | m_batchEventProcessors[i]->halt(); |
| 81 | PerfTestUtil::failIfNot(m_results[i], m_handlers[i]->value(), |
| 82 | "Result " + std::to_string(m_results[i]) + " != " + std::to_string(m_handlers[i]->value())); |
| 83 | } |
| 84 | |
| 85 | for (auto&& task : processorTasks) |
| 86 | task.wait(); |
| 87 | |
| 88 | return m_numEventProcessors * m_iterations; |
| 89 | } |
| 90 | |
| 91 | std::int32_t OneToThreeSequencedThroughputTest::requiredProcessorCount() const |
| 92 | { |