memgraph/tests/concurrent/dynamic_bitset_set.cpp

29 lines
632 B
C++
Raw Normal View History

2016-08-03 00:05:10 +08:00
#include "common.h"
2016-12-22 22:51:16 +08:00
constexpr size_t THREADS_NO = std::min(max_no_threads, 8);
2016-08-03 00:05:10 +08:00
constexpr size_t op_per_thread = 1e5;
2016-12-22 22:51:16 +08:00
constexpr size_t key_range = op_per_thread * THREADS_NO * 3;
// TODO: document the test
2016-08-03 00:05:10 +08:00
int main()
{
DynamicBitset<> db;
2016-12-22 22:51:16 +08:00
2016-08-03 00:05:10 +08:00
auto set = collect_set(run<std::vector<bool>>(THREADS_NO, [&](auto index) {
auto rand = rand_gen(key_range);
std::vector<bool> set(key_range);
2016-12-22 22:51:16 +08:00
for (size_t i = 0; i < op_per_thread; i++)
{
2016-08-03 00:05:10 +08:00
size_t num = rand();
db.set(num);
set[num] = true;
}
return set;
}));
check_set(db, set);
}