GetConfigNonZeroExpected(LeapfrogPassCount, 850000000);
}
- template <typename Map> static void run_test(Map* map, size_t pass_count) {
+ template <typename Map>
+ static void run_test(Map* map, size_t pass_count, size_t* inserted_num,
+ size_t* deleted_num) {
auto qsbrContext = junction::DefaultQSBR.createContext();
std::random_device rd;
unsigned action_index = 0;
size_t nInsertedNum = 0;
+ size_t nDeletedNum = 0;
size_t nFindSuccess = 0;
size_t nOperations = 0;
break;
}
case do_delete: {
- map_delete(map, key);
+ if (map_delete(map, key)) {
+ nDeletedNum++;
+ }
break;
}
case do_find: {
}
junction::DefaultQSBR.update(qsbrContext);
junction::DefaultQSBR.destroyContext(qsbrContext);
+ *inserted_num = nInsertedNum;
+ *deleted_num = nDeletedNum;
}
};
size_t JunctionMapInsDelFindTest_Parallel::s_nLeapfrogPassCount;
#define JunctionThreading(map_type, pass_count) \
- std::unique_ptr<std::thread[]> threads(new std::thread[s_nThreadCount]); \
- for (size_t i = 0; i < s_nThreadCount; i++) { \
- threads[i] = std::thread(run_test<map_type>, map.get(), pass_count); \
+ std::unique_ptr<std::thread[]> threads(new std::thread[s_nThreadCount]); \
+ std::unique_ptr<size_t[]> inserted_nums(new size_t[s_nThreadCount]); \
+ std::unique_ptr<size_t[]> deleted_nums(new size_t[s_nThreadCount]); \
+ for (size_t i = 0; i < s_nThreadCount; i++) { \
+ threads[i] = std::thread(run_test<map_type>, map.get(), pass_count, \
+ &inserted_nums[i], &deleted_nums[i]); \
} \
- for (size_t i = 0; i < s_nThreadCount; i++) { \
+ size_t inserted_sum = 0; \
+ size_t deleted_sum = 0; \
+ for (size_t i = 0; i < s_nThreadCount; i++) { \
threads[i].join(); \
- }
+ inserted_sum += inserted_nums[i]; \
+ deleted_sum += deleted_nums[i]; \
+ } \
+ EXPECT_LE(deleted_sum, inserted_sum);
TEST_F(JunctionMapInsDelFindTest_Parallel, JunctionMapCrude) {
std::unique_ptr<CrudeMap> map(new CrudeMap(s_nCrudeMapCapacity));