MCPcopy Create free account
hub / github.com/DigitalInBlue/Celero / startThreads

Method startThreads

src/ThreadTestFixture.cpp:48–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48void ThreadTestFixture::startThreads(uint64_t threads, uint64_t iterations)
49{
50 const uint64_t iterationsPerThread = iterations / threads;
51
52 for(uint64_t i = 0; i < threads; ++i)
53 {
54 try
55 {
56 this->pimpl->futures.push_back(
57 // std::async(std::launch::deferred,
58 std::async(std::launch::async, [this, i, iterationsPerThread]() {
59 this->pimpl->currentThreadId = i + 1;
60 for(auto threadIterationCounter = size_t(0); threadIterationCounter < iterationsPerThread;)
61 {
62 this->pimpl->currentCallId = ++threadIterationCounter;
63 this->UserBenchmark();
64 }
65 }));
66 }
67 catch(std::system_error& e)
68 {
69 std::cerr << "ERROR: Exception. Error Code: " << e.code() << ", " << e.what() << "\n";
70 }
71 }
72}
73
74void ThreadTestFixture::stopThreads()
75{

Callers 1

runMethod · 0.95

Calls 3

push_backMethod · 0.80
UserBenchmarkMethod · 0.80
whatMethod · 0.80

Tested by

no test coverage detected