X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=test%2Fstress%2Fsequential%2Fsequential-map%2Finsdel_string%2Fmap_insdel_string.h;h=dcd6d4ffb5ea48ca4a5aa66b5c110fa894601f1b;hb=2f8bc17e37a31d7eea67e4dc40a10a47ff63bb75;hp=35cf825546270e213841caf05e65859b1c3a5831;hpb=3a3e05a161168102d2666e4f606178ee0b4a37c5;p=libcds.git diff --git a/test/stress/sequential/sequential-map/insdel_string/map_insdel_string.h b/test/stress/sequential/sequential-map/insdel_string/map_insdel_string.h index 35cf8255..dcd6d4ff 100644 --- a/test/stress/sequential/sequential-map/insdel_string/map_insdel_string.h +++ b/test/stress/sequential/sequential-map/insdel_string/map_insdel_string.h @@ -41,6 +41,12 @@ namespace map { static size_t s_nInsertThreadCount; // count of insertion thread static size_t s_nDeleteThreadCount; // count of deletion thread static size_t s_nThreadPassCount; // pass count for each thread + 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_nMaxLoadFactor; // maximum load factor static size_t s_nCuckooInitialSize; // initial size for CuckooMap @@ -99,25 +105,12 @@ namespace map { { Map& rMap = m_Map; - if ( id() & 1 ) { - for ( size_t nPass = 0; nPass < s_nThreadPassCount; ++nPass ) { - for ( auto it = s_arrKeys.cbegin(), itEnd = s_arrKeys.cend(); it != itEnd; ++it ) { - if ( rMap.insert( *it, 0 )) - ++m_nInsertSuccess; - else - ++m_nInsertFailed; - } - } - } - else { - for ( size_t nPass = 0; nPass < s_nThreadPassCount; ++nPass ) { - for ( auto it = s_arrKeys.crbegin(), itEnd = s_arrKeys.crend(); it != itEnd; ++it ) { - if ( rMap.insert( *it, 1 )) - ++m_nInsertSuccess; - else - ++m_nInsertFailed; - } - } + for (auto it = s_arrKeys.cbegin(), itEnd = s_arrKeys.cend(); + it != itEnd; ++it) { + if (rMap.insert(*it, 0)) + ++m_nInsertSuccess; + else + ++m_nInsertFailed; } } }; @@ -152,25 +145,12 @@ namespace map { { Map& rMap = m_Map; - if ( id() & 1 ) { - for ( size_t nPass = 0; nPass < s_nThreadPassCount; ++nPass ) { - for ( auto it = s_arrKeys.cbegin(), itEnd = s_arrKeys.cend(); it != itEnd; ++it ) { - if ( rMap.erase( *it )) - ++m_nDeleteSuccess; - else - ++m_nDeleteFailed; - } - } - } - else { - for ( size_t nPass = 0; nPass < s_nThreadPassCount; ++nPass ) { - for ( auto it = s_arrKeys.crbegin(), itEnd = s_arrKeys.crend(); it != itEnd; ++it ) { - if ( rMap.erase( *it )) - ++m_nDeleteSuccess; - else - ++m_nDeleteFailed; - } - } + for (auto it = s_arrKeys.cbegin(), itEnd = s_arrKeys.cend(); + it != itEnd; ++it) { + if (rMap.erase(*it)) + ++m_nDeleteSuccess; + else + ++m_nDeleteFailed; } } }; @@ -186,62 +166,20 @@ namespace map { typedef Deleter deleter; cds_test::thread_pool& pool = get_pool(); - pool.add( new inserter( pool, testMap ), s_nInsertThreadCount ); - pool.add( new deleter( pool, testMap ), s_nDeleteThreadCount ); - - propout() << std::make_pair( "insert_thread_count", s_nInsertThreadCount ) - << std::make_pair( "delete_thread_count", s_nDeleteThreadCount ) - << std::make_pair( "pass_count", s_nThreadPassCount ) - << std::make_pair( "map_size", s_nMapSize ); - - std::chrono::milliseconds duration = pool.run(); - - propout() << std::make_pair( "duration", duration ); - - size_t nInsertSuccess = 0; - size_t nInsertFailed = 0; - size_t nDeleteSuccess = 0; - size_t nDeleteFailed = 0; - - for ( size_t i = 0; i < pool.size(); ++i ) { - cds_test::thread& thr = pool.get( i ); - switch ( thr.type()) { - case insert_thread: - { - inserter& t = static_cast(thr); - nInsertSuccess += t.m_nInsertSuccess; - nInsertFailed += t.m_nInsertFailed; - } - break; - case delete_thread: - { - deleter& t = static_cast(thr); - nDeleteSuccess += t.m_nDeleteSuccess; - nDeleteFailed += t.m_nDeleteFailed; - } - break; - default: - assert( false ); - } + std::unique_ptr inserter_thrd( + new inserter(pool, testMap)); + std::unique_ptr deleter_thrd( + new deleter(pool, testMap)); + for (size_t nPass = 0; nPass < s_nThreadPassCount; ++nPass) { + inserter_thrd->test(); + deleter_thrd->test(); } - propout() - << std::make_pair( "insert_success", nInsertSuccess ) - << std::make_pair( "insert_failed", nInsertFailed ) - << std::make_pair( "delete_success", nDeleteSuccess ) - << std::make_pair( "delete_failed", nDeleteFailed ) - << std::make_pair( "finish_map_size", testMap.size()); - - check_before_cleanup( testMap ); - - //testMap.clear(); + // testMap.clear(); for ( auto const& str: s_arrKeys ) testMap.erase( str ); EXPECT_TRUE( testMap.empty()); EXPECT_EQ( testMap.size(), 0u ); - - additional_check( testMap ); - print_stat( propout(), testMap ); additional_cleanup( testMap ); } @@ -250,6 +188,41 @@ namespace map { { Map testMap( *this ); do_test( testMap ); + } + + template + void run_bronson_avl_tree() { + Map_InsDel_string::s_nThreadPassCount = + Map_InsDel_string::s_nBronsonAVLTreeMapPassCount; + run_test(); + } + + template + void run_ellen_bin_tree() { + Map_InsDel_string::s_nThreadPassCount = + Map_InsDel_string::s_nEllenBinTreeMapPassCount; + run_test(); + } + + template + void run_feldman() { + Map_InsDel_string::s_nThreadPassCount = + Map_InsDel_string::s_nFeldmanPassCount; + run_test(); + } + + template + void run_michael() { + Map_InsDel_string::s_nThreadPassCount = + Map_InsDel_string::s_nMichaelMapPassCount; + run_test(); + } + + template + void run_skip_list() { + Map_InsDel_string::s_nThreadPassCount = + Map_InsDel_string::s_nSkipListMapPassCount; + run_test(); } };