MCPcopy Create free account
hub / github.com/Abc-Arbitrage/Disruptor-cpp / run

Method run

Disruptor.PerfTests/OneToThreeSequencedThroughputTest.cpp:50–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 11

failIfNotFunction · 0.85
startMethod · 0.45
stopMethod · 0.45
resetMethod · 0.45
valueMethod · 0.45
sequenceMethod · 0.45
executeMethod · 0.45
nextMethod · 0.45
publishMethod · 0.45
waitMethod · 0.45
haltMethod · 0.45

Tested by

no test coverage detected