void test(Test &t) { std::vector<std::thread> producers; std::vector<std::thread> consumers; // XXX: we should probably synchronize thread starting work and // just time the actual work. BenchTimer timer; for (int i = 0; i < t.producers; i++) { producers.push_back(std::thread(producer, &t)); } for (int i = 0; i < t.consumers; i++) { consumers.push_back(std::thread(consumer, &t, i)); } joinAll(consumers); timer.stop(); t.consumersDone = true; joinAll(producers); //printf("Max thing: %ld\n", t.totalSum.load()); timer.report(t.count * t.consumers, !BenchMode); }
void test(Test &t) { build_list(&t.noobs, 100); std::vector<std::thread> producers; std::vector<std::thread> consumers; // XXX: we should probably synchronize thread starting work and // just time the actual work. BenchTimer timer; for (int i = 0; i < t.producers; i++) { producers.push_back(std::thread(producer, &t, i)); } for (int i = 0; i < t.consumers; i++) { consumers.push_back(std::thread(consumer, &t, i)); } joinAll(consumers); timer.stop(); t.consumersDone = true; joinAll(producers); timer.report(t.count * t.consumers, !BenchMode); }