in benchmarks/simple_pool_benchmark.cpp [166:198]
void BM_dispenso_mostly_idle(benchmark::State& state) {
const int num_threads = state.range(0);
const int num_elements = state.range(1);
struct Recurse {
void operator()() {
work[tid() & 1023] += i;
if (i < num_elements) {
++i;
pool->schedule(*this);
}
}
int i;
Work* work;
dispenso::ThreadPool* pool;
int num_elements;
};
startRusage();
for (auto UNUSED_VAR : state) {
dispenso::ThreadPool pool(num_threads);
Recurse rec;
rec.i = 0;
rec.work = g_work;
rec.pool = &pool;
rec.num_elements = num_elements;
rec();
}
endRusage(state);
}