#include <folly/experimental/EventCount.h>
#include <algorithm>
#include <atomic>
#include <random>
#include <thread>
#include <vector>
#include <glog/logging.h>
#include <folly/Random.h>
#include <folly/portability/GTest.h>
Go to the source code of this file.
Definition at line 82 of file EventCountTest.cpp.
References count, EXPECT_EQ, ops, folly::randomNumberSeed(), and threads.
84 static const size_t count = 300000;
90 std::vector<std::pair<Op, int>>
ops;
92 randomPartition(rnd, Op::UP, count, ops);
93 size_t uppers = ops.size();
94 randomPartition(rnd, Op::DOWN, count, ops);
95 size_t downers = ops.size() - uppers;
96 VLOG(1) <<
"Using " << ops.size() <<
" threads: uppers=" << uppers
97 <<
" downers=" << downers <<
" sem_count=" <<
count;
99 std::shuffle(ops.begin(), ops.end(), std::mt19937(std::random_device()()));
101 std::vector<std::thread>
threads;
102 threads.reserve(ops.size());
105 for (
auto&
op : ops) {
107 if (
op.first == Op::UP) {
108 auto fn = [&sem, n]()
mutable {
113 threads.push_back(std::thread(fn));
115 auto fn = [&sem, n]()
mutable {
120 threads.push_back(std::thread(fn));
124 for (
auto& thread : threads) {
#define EXPECT_EQ(val1, val2)
std::vector< std::thread::id > threads
uint32_t randomNumberSeed()