static size_t s_nMapSize; // map size (count of searching item)
static size_t s_nPercentExists; // percent of existing keys in searching sequence
static size_t s_nPassCount;
+ static size_t s_nBronsonAVLTreeMapPassCount;
+ static size_t s_nEllenBinTreeMapPassCount;
+ static size_t s_nFeldmanPassCount;
+ static size_t s_nMichaelMapPassCount;
+ static size_t s_nSkipListMapPassCount;
+ static size_t s_nSplitListMapPassCount;
+
static size_t s_nMaxLoadFactor; // maximum load factor
static size_t s_nCuckooInitialSize; // initial size for CuckooMap
size_t const nPassCount = s_nPassCount;
Map& rMap = m_Map;
- for ( size_t nPass = 0; nPass < nPassCount; ++nPass ) {
- if ( id() & 1 ) {
- auto itEnd = s_Data.cend();
- for ( auto it = s_Data.cbegin(); it != itEnd; ++it ) {
- auto bFound = rMap.contains( *(it->pKey));
- if ( it->bExists ) {
- if ( check_result(bFound, rMap))
- ++m_KeyExists.nSuccess;
- else
- ++m_KeyExists.nFailed;
- }
- else {
- if ( check_result(bFound, rMap))
- ++m_KeyNotExists.nFailed;
- else
- ++m_KeyNotExists.nSuccess;
- }
- }
- }
- else {
- auto itEnd = s_Data.crend();
- for ( auto it = s_Data.crbegin(); it != itEnd; ++it ) {
- auto bFound = rMap.contains( *(it->pKey));
- if ( it->bExists ) {
- if ( check_result(bFound, rMap))
- ++m_KeyExists.nSuccess;
- else
- ++m_KeyExists.nFailed;
- }
- else {
- if ( check_result( bFound, rMap ))
- ++m_KeyNotExists.nFailed;
- else
- ++m_KeyNotExists.nSuccess;
- }
- }
+ for (size_t nPass = 0; nPass < nPassCount; ++nPass) {
+ auto itEnd = s_Data.cend();
+ for (auto it = s_Data.cbegin(); it != itEnd; ++it) {
+ auto bFound = rMap.contains(*(it->pKey));
+ if (it->bExists) {
+ if (check_result(bFound, rMap))
+ ++m_KeyExists.nSuccess;
+ else
+ ++m_KeyExists.nFailed;
+ } else {
+ if (check_result(bFound, rMap))
+ ++m_KeyNotExists.nFailed;
+ else
+ ++m_KeyNotExists.nSuccess;
}
+ }
}
}
};
}
}
- propout() << std::make_pair( "thread_count", s_nThreadCount )
- << std::make_pair( "map_size", s_nMapSize )
- << std::make_pair( "percent_exist", s_nPercentExists )
- << std::make_pair( "pass_count", s_nPassCount );
-
- cds_test::thread_pool& pool = get_pool();
- pool.add( new worker( pool, testMap ), s_nThreadCount );
-
- std::chrono::milliseconds duration = pool.run();
-
- propout() << std::make_pair( "duration", duration );
-
- size_t nExistSuccess = 0;
- size_t nExistFailed = 0;
- size_t nMissingSuccess = 0;
- size_t nMissingFailed = 0;
-
- // Postcondition: the number of success searching == the number of map item
- for ( size_t i = 0; i < pool.size(); ++i ) {
- worker& w = static_cast<worker&>(pool.get( i ));
- nExistSuccess += w.m_KeyExists.nSuccess;
- nExistFailed += w.m_KeyExists.nFailed;
- nMissingSuccess += w.m_KeyNotExists.nSuccess;
- nMissingFailed += w.m_KeyNotExists.nFailed;
-
- EXPECT_EQ( w.m_KeyExists.nSuccess, s_nMapSize * s_nPassCount ) << "thread " << i;
- EXPECT_EQ( w.m_KeyExists.nFailed, 0u ) << "thread " << i;
- EXPECT_EQ( w.m_KeyNotExists.nSuccess, (s_Data.size() - s_nMapSize) * s_nPassCount ) << "thread " << i;
- EXPECT_EQ( w.m_KeyNotExists.nFailed, 0u ) << "thread " << i;
- }
-
- propout()
- << std::make_pair( "exist_found", nExistSuccess )
- << std::make_pair( "exist_not_found", nExistFailed ) // must = 0
- << std::make_pair( "missing_not_found", nMissingSuccess )
- << std::make_pair( "missing_found", nMissingFailed ); // must = 0
-
- check_before_cleanup( testMap );
+ cds_test::thread_pool &pool = get_pool();
+ std::unique_ptr<worker> worker_thread(new worker(pool, testMap));
+ worker_thread->test();
testMap.clear();
- additional_check( testMap );
- print_stat( propout(), testMap );
- additional_cleanup( testMap );
+ additional_cleanup(testMap);
}
template <class Map>
Map testMap( *this );
test( testMap );
}
+
+ template <class Map>
+ void run_bronson_avl_tree() {
+ Map_find_string::s_nPassCount =
+ Map_find_string::s_nBronsonAVLTreeMapPassCount;
+ run_test<Map>();
+ }
+
+ template <class Map>
+ void run_ellen_bin_tree() {
+ Map_find_string::s_nPassCount =
+ Map_find_string::s_nEllenBinTreeMapPassCount;
+ run_test<Map>();
+ }
+
+ template <class Map>
+ void run_feldman() {
+ Map_find_string::s_nPassCount =
+ Map_find_string::s_nFeldmanPassCount;
+ run_test<Map>();
+ }
+
+ template <class Map>
+ void run_michael() {
+ Map_find_string::s_nPassCount =
+ Map_find_string::s_nMichaelMapPassCount;
+ run_test<Map>();
+ }
+
+ template <class Map>
+ void run_skip_list() {
+ Map_find_string::s_nPassCount =
+ Map_find_string::s_nSkipListMapPassCount;
+ run_test<Map>();
+ }
+
+ template <class Map>
+ void run_split_list() {
+ Map_find_string::s_nPassCount =
+ Map_find_string::s_nSplitListMapPassCount;
+ run_test<Map>();
+ }
+
};
class Map_find_string_stdhash: public Map_find_string