From 2c74c6f74b193317bc2d6bb8718216b7cd87831b Mon Sep 17 00:00:00 2001 From: khizmax Date: Fri, 27 Mar 2015 11:45:48 +0300 Subject: [PATCH] Splitted up map_insdel_item_string test --- projects/Win/vc12/unit-map-insdel.vcxproj | 9 + .../Win/vc12/unit-map-insdel.vcxproj.filters | 27 ++ projects/source.unit.map.mk | 10 +- tests/unit/map2/map_insdel_item_int.h | 1 - tests/unit/map2/map_insdel_item_string.cpp | 311 ++---------------- tests/unit/map2/map_insdel_item_string.h | 279 ++++++++++++++++ .../map_insdel_item_string_bronsonavltree.cpp | 9 + .../map2/map_insdel_item_string_cuckoo.cpp | 9 + .../map2/map_insdel_item_string_ellentree.cpp | 9 + .../map2/map_insdel_item_string_michael.cpp | 9 + .../map2/map_insdel_item_string_refinable.cpp | 9 + .../unit/map2/map_insdel_item_string_skip.cpp | 9 + .../map2/map_insdel_item_string_split.cpp | 9 + .../map2/map_insdel_item_string_striped.cpp | 9 + 14 files changed, 426 insertions(+), 283 deletions(-) create mode 100644 tests/unit/map2/map_insdel_item_string.h create mode 100644 tests/unit/map2/map_insdel_item_string_bronsonavltree.cpp create mode 100644 tests/unit/map2/map_insdel_item_string_cuckoo.cpp create mode 100644 tests/unit/map2/map_insdel_item_string_ellentree.cpp create mode 100644 tests/unit/map2/map_insdel_item_string_michael.cpp create mode 100644 tests/unit/map2/map_insdel_item_string_refinable.cpp create mode 100644 tests/unit/map2/map_insdel_item_string_skip.cpp create mode 100644 tests/unit/map2/map_insdel_item_string_split.cpp create mode 100644 tests/unit/map2/map_insdel_item_string_striped.cpp diff --git a/projects/Win/vc12/unit-map-insdel.vcxproj b/projects/Win/vc12/unit-map-insdel.vcxproj index d55cae75..72364e8a 100644 --- a/projects/Win/vc12/unit-map-insdel.vcxproj +++ b/projects/Win/vc12/unit-map-insdel.vcxproj @@ -81,6 +81,14 @@ + + + + + + + + @@ -97,6 +105,7 @@ + diff --git a/projects/Win/vc12/unit-map-insdel.vcxproj.filters b/projects/Win/vc12/unit-map-insdel.vcxproj.filters index 4e436272..dc73d3e8 100644 --- a/projects/Win/vc12/unit-map-insdel.vcxproj.filters +++ b/projects/Win/vc12/unit-map-insdel.vcxproj.filters @@ -145,6 +145,30 @@ map_insdel_item_int + + map_insdel_item_string + + + map_insdel_item_string + + + map_insdel_item_string + + + map_insdel_item_string + + + map_insdel_item_string + + + map_insdel_item_string + + + map_insdel_item_string + + + map_insdel_item_string + @@ -182,5 +206,8 @@ map_insdel_item_int + + map_insdel_item_string + \ No newline at end of file diff --git a/projects/source.unit.map.mk b/projects/source.unit.map.mk index bbc33788..0f85cb35 100644 --- a/projects/source.unit.map.mk +++ b/projects/source.unit.map.mk @@ -58,6 +58,15 @@ CDSUNIT_MAP_SOURCES := \ tests/unit/map2/map_insdel_item_int_striped.cpp \ tests/unit/map2/map_insdel_item_int_refinable.cpp \ tests/unit/map2/map_insdel_item_int_cuckoo.cpp \ + tests/unit/map2/map_insdel_item_string.cpp \ + tests/unit/map2/map_insdel_item_string_michael.cpp \ + tests/unit/map2/map_insdel_item_string_split.cpp \ + tests/unit/map2/map_insdel_item_string_skip.cpp \ + tests/unit/map2/map_insdel_item_string_ellentree.cpp \ + tests/unit/map2/map_insdel_item_string_bronsonavltree.cpp \ + tests/unit/map2/map_insdel_item_string_striped.cpp \ + tests/unit/map2/map_insdel_item_string_refinable.cpp \ + tests/unit/map2/map_insdel_item_string_cuckoo.cpp \ tests/unit/map2/map_insdel_string.cpp \ tests/unit/map2/map_insdel_string_michael.cpp \ tests/unit/map2/map_insdel_string_split.cpp \ @@ -68,7 +77,6 @@ CDSUNIT_MAP_SOURCES := \ tests/unit/map2/map_insdel_string_refinable.cpp \ tests/unit/map2/map_insdel_string_cuckoo.cpp \ tests/unit/map2/map_insdel_string_std.cpp \ - tests/unit/map2/map_insdel_item_string.cpp \ tests/unit/map2/map_insdelfind.cpp \ tests/unit/map2/map_insdelfind_michael.cpp \ tests/unit/map2/map_insdelfind_split.cpp \ diff --git a/tests/unit/map2/map_insdel_item_int.h b/tests/unit/map2/map_insdel_item_int.h index 1b4cf431..cc117768 100644 --- a/tests/unit/map2/map_insdel_item_int.h +++ b/tests/unit/map2/map_insdel_item_int.h @@ -266,7 +266,6 @@ namespace map2 { virtual void myRun(const char *in_name, bool invert = false); - # include "map2/map_defs.h" CDSUNIT_DECLARE_MichaelMap CDSUNIT_DECLARE_SplitList diff --git a/tests/unit/map2/map_insdel_item_string.cpp b/tests/unit/map2/map_insdel_item_string.cpp index fd062d1c..09980ce8 100644 --- a/tests/unit/map2/map_insdel_item_string.cpp +++ b/tests/unit/map2/map_insdel_item_string.cpp @@ -1,291 +1,40 @@ //$$CDS-header$$ -#include "map2/map_types.h" -#include "cppunit/thread.h" - -#include +#include "map2/map_insdel_item_string.h" namespace map2 { + CPPUNIT_TEST_SUITE_REGISTRATION( Map_InsDel_Item_string ); -# define TEST_MAP(X) void X() { test::X >() ; } -# define TEST_MAP_NOLF(X) void X() { test_nolf::X >() ; } -# define TEST_MAP_EXTRACT(X) TEST_MAP(X) -# define TEST_MAP_NOLF_EXTRACT(X) TEST_MAP_NOLF(X) + size_t Map_InsDel_Item_string::c_nMapSize = 1000000; + size_t Map_InsDel_Item_string::c_nThreadCount = 4; + size_t Map_InsDel_Item_string::c_nGoalItem = c_nMapSize / 2; + size_t Map_InsDel_Item_string::c_nAttemptCount = 100000; + size_t Map_InsDel_Item_string::c_nMaxLoadFactor = 8; + bool Map_InsDel_Item_string::c_bPrintGCState = true; - namespace { - static size_t c_nMapSize = 1000000 ; // map size - static size_t c_nThreadCount = 4 ; // thread count - static size_t c_nGoalItem = c_nMapSize / 2; - static size_t c_nAttemptCount = 100000 ; // count of SUCCESS insert/delete for each thread - static size_t c_nMaxLoadFactor = 8 ; // maximum load factor - static bool c_bPrintGCState = true; + void Map_InsDel_Item_string::setUpParams( const CppUnitMini::TestCfg& cfg ) + { + c_nThreadCount = cfg.getSizeT("ThreadCount", c_nThreadCount ); + c_nMapSize = cfg.getSizeT("MapSize", c_nMapSize ); + c_nGoalItem = cfg.getSizeT("GoalItemIndex", c_nGoalItem); + c_nAttemptCount = cfg.getSizeT("AttemptCount", c_nAttemptCount ); + c_nMaxLoadFactor = cfg.getSizeT("MaxLoadFactor", c_nMaxLoadFactor ); + c_bPrintGCState = cfg.getBool("PrintGCStateFlag", true ); } - class Map_InsDel_Item_string: public CppUnitMini::TestCase + void Map_InsDel_Item_string::myRun(const char *in_name, bool invert /*= false*/) { - typedef std::string key_type; - typedef size_t value_type; - - const std::vector * m_parrString; - - template - class Inserter: public CppUnitMini::TestThread - { - Map& m_Map; - - virtual Inserter * clone() - { - return new Inserter( *this ); - } - public: - size_t m_nInsertSuccess; - size_t m_nInsertFailed; - - public: - Inserter( CppUnitMini::ThreadPool& pool, Map& rMap ) - : CppUnitMini::TestThread( pool ) - , m_Map( rMap ) - {} - Inserter( Inserter& src ) - : CppUnitMini::TestThread( src ) - , m_Map( src.m_Map ) - {} - - Map_InsDel_Item_string& getTest() - { - return reinterpret_cast( m_Pool.m_Test ); - } - - virtual void init() { cds::threading::Manager::attachThread() ; } - virtual void fini() { cds::threading::Manager::detachThread() ; } - - virtual void test() - { - Map& rMap = m_Map; - - m_nInsertSuccess = - m_nInsertFailed = 0; - - size_t nGoalItem = c_nGoalItem; - std::string strGoal = (*getTest().m_parrString)[nGoalItem]; - - for ( size_t nAttempt = 0; nAttempt < c_nAttemptCount; ) { - if ( rMap.insert( strGoal, nGoalItem )) { - ++m_nInsertSuccess; - ++nAttempt; - } - else - ++m_nInsertFailed; - } - } - }; - - template - class Deleter: public CppUnitMini::TestThread - { - Map& m_Map; - - struct erase_cleaner { - void operator ()(std::pair& val ) - { - val.second = 0; - } - // for boost::container::flat_map - void operator ()(std::pair< typename std::remove_const< typename Map::key_type >::type, typename Map::mapped_type>& val ) - { - val.second = 0; - } - // for BronsonAVLTreeMap - void operator()( typename Map::key_type const& /*key*/, typename Map::mapped_type& val ) - { - val = 0; - } - }; - - virtual Deleter * clone() - { - return new Deleter( *this ); - } - public: - size_t m_nDeleteSuccess; - size_t m_nDeleteFailed; - - public: - Deleter( CppUnitMini::ThreadPool& pool, Map& rMap ) - : CppUnitMini::TestThread( pool ) - , m_Map( rMap ) - {} - Deleter( Deleter& src ) - : CppUnitMini::TestThread( src ) - , m_Map( src.m_Map ) - {} - - Map_InsDel_Item_string& getTest() - { - return reinterpret_cast( m_Pool.m_Test ); - } - - virtual void init() { cds::threading::Manager::attachThread() ; } - virtual void fini() { cds::threading::Manager::detachThread() ; } - - virtual void test() - { - Map& rMap = m_Map; - - m_nDeleteSuccess = - m_nDeleteFailed = 0; - - size_t nGoalItem = c_nGoalItem; - std::string strGoal = (*getTest().m_parrString)[nGoalItem]; - - for ( size_t nAttempt = 0; nAttempt < c_nAttemptCount; ) { - if ( rMap.erase( strGoal, erase_cleaner() )) { - ++m_nDeleteSuccess; - ++nAttempt; - } - else - ++m_nDeleteFailed; - } - } - }; - - protected: - - template - void do_test( Map& testMap ) - { - typedef Inserter InserterThread; - typedef Deleter DeleterThread; - cds::OS::Timer timer; - - // Fill the map - CPPUNIT_MSG( " Fill map (" << c_nMapSize << " items)..."); - timer.reset(); - for ( size_t i = 0; i < c_nMapSize; ++i ) { - CPPUNIT_ASSERT_EX( testMap.insert( (*m_parrString)[i], i ), i ); - } - CPPUNIT_MSG( " Duration=" << timer.duration() ); - - CPPUNIT_MSG( " Insert/delete the key " << c_nGoalItem << " (" << c_nAttemptCount << " successful times)..."); - CppUnitMini::ThreadPool pool( *this ); - pool.add( new InserterThread( pool, testMap ), (c_nThreadCount + 1) / 2 ); - pool.add( new DeleterThread( pool, testMap ), (c_nThreadCount + 1) / 2 ); - pool.run(); - CPPUNIT_MSG( " Duration=" << pool.avgDuration() ); - - size_t nInsertSuccess = 0; - size_t nInsertFailed = 0; - size_t nDeleteSuccess = 0; - size_t nDeleteFailed = 0; - for ( CppUnitMini::ThreadPool::iterator it = pool.begin(); it != pool.end(); ++it ) { - InserterThread * pThread = dynamic_cast( *it ); - if ( pThread ) { - CPPUNIT_CHECK( pThread->m_nInsertSuccess == c_nAttemptCount ); - nInsertSuccess += pThread->m_nInsertSuccess; - nInsertFailed += pThread->m_nInsertFailed; - } - else { - DeleterThread * p = static_cast( *it ); - CPPUNIT_CHECK( p->m_nDeleteSuccess == c_nAttemptCount ); - nDeleteSuccess += p->m_nDeleteSuccess; - nDeleteFailed += p->m_nDeleteFailed; - } - } - CPPUNIT_CHECK_EX( nInsertSuccess == nDeleteSuccess, "nInsertSuccess=" << nInsertSuccess << ", nDeleteSuccess=" << nDeleteSuccess ); - CPPUNIT_MSG( " Totals: Ins fail=" << nInsertFailed << " Del fail=" << nDeleteFailed ); - - // Check if the map contains all items - CPPUNIT_MSG( " Check if the map contains all items" ); - timer.reset(); - for ( size_t i = 0; i < c_nMapSize; ++i ) { - CPPUNIT_CHECK_EX( testMap.find( (*m_parrString)[i] ), "Key \"" << (*m_parrString)[i] << "\" not found" ); - } - CPPUNIT_MSG( " Duration=" << timer.duration() ); - - check_before_cleanup( testMap ); - - testMap.clear(); - additional_check( testMap ); - print_stat( testMap ); - additional_cleanup( testMap ); - } - - template - void test() - { - m_parrString = &CppUnitMini::TestCase::getTestStrings(); - if ( c_nMapSize > m_parrString->size() ) - c_nMapSize = m_parrString->size(); - if ( c_nGoalItem > m_parrString->size() ) - c_nGoalItem = m_parrString->size() / 2; - - CPPUNIT_MSG( "Thread count= " << c_nThreadCount - << " pass count=" << c_nAttemptCount - << " map size=" << c_nMapSize - ); - - for ( size_t nLoadFactor = 1; nLoadFactor <= c_nMaxLoadFactor; nLoadFactor *= 2 ) { - CPPUNIT_MSG( "Load factor=" << nLoadFactor ); - Map testMap( c_nMapSize, nLoadFactor ); - do_test( testMap ); - if ( c_bPrintGCState ) - print_gc_state(); - } - } - - template - void test_nolf() - { - m_parrString = &CppUnitMini::TestCase::getTestStrings(); - if ( c_nMapSize > m_parrString->size() ) - c_nMapSize = m_parrString->size(); - if ( c_nGoalItem > m_parrString->size() ) - c_nGoalItem = m_parrString->size() / 2; - - CPPUNIT_MSG( "Thread count= " << c_nThreadCount - << " pass count=" << c_nAttemptCount - << " map size=" << c_nMapSize - ); - - Map testMap; - do_test( testMap ); - if ( c_bPrintGCState ) - print_gc_state(); - } - - void setUpParams( const CppUnitMini::TestCfg& cfg ) { - c_nThreadCount = cfg.getULong("ThreadCount", 8 ) ; // thread count - c_nMapSize = cfg.getULong("MapSize", 1000000 ); - c_nGoalItem = cfg.getULong("GoalItemIndex", (unsigned long) (c_nMapSize / 2) ); - c_nAttemptCount = cfg.getULong("AttemptCount", 100000 ); - c_nMaxLoadFactor = cfg.getULong("MaxLoadFactor", 8 ); - c_bPrintGCState = cfg.getBool("PrintGCStateFlag", true ); - } - -# include "map2/map_defs.h" - CDSUNIT_DECLARE_MichaelMap - CDSUNIT_DECLARE_SplitList - CDSUNIT_DECLARE_SkipListMap - CDSUNIT_DECLARE_EllenBinTreeMap - CDSUNIT_DECLARE_BronsonAVLTreeMap - CDSUNIT_DECLARE_StripedMap - CDSUNIT_DECLARE_RefinableMap - CDSUNIT_DECLARE_CuckooMap - CDSUNIT_DECLARE_StdMap - - CPPUNIT_TEST_SUITE( Map_InsDel_Item_string ) - CDSUNIT_TEST_MichaelMap - CDSUNIT_TEST_SplitList - CDSUNIT_TEST_SkipListMap - CDSUNIT_TEST_EllenBinTreeMap - CDSUNIT_TEST_BronsonAVLTreeMap - CDSUNIT_TEST_StripedMap - CDSUNIT_TEST_RefinableMap - CDSUNIT_TEST_CuckooMap - //CDSUNIT_TEST_StdMap // very slow!!! - CPPUNIT_TEST_SUITE_END() - - }; - - CPPUNIT_TEST_SUITE_REGISTRATION( Map_InsDel_Item_string ); + setUpParams( m_Cfg.get( "Map_InsDel_Item_string" )); + + run_MichaelMap(in_name, invert); + run_SplitList(in_name, invert); + run_SkipListMap(in_name, invert); + run_EllenBinTreeMap(in_name, invert); + run_BronsonAVLTreeMap(in_name, invert); + run_StripedMap(in_name, invert); + run_RefinableMap(in_name, invert); + run_CuckooMap(in_name, invert); + + endTestCase(); + } } // namespace map2 diff --git a/tests/unit/map2/map_insdel_item_string.h b/tests/unit/map2/map_insdel_item_string.h new file mode 100644 index 00000000..b42450c4 --- /dev/null +++ b/tests/unit/map2/map_insdel_item_string.h @@ -0,0 +1,279 @@ +//$$CDS-header$$ + +#include "map2/map_types.h" +#include "cppunit/thread.h" + +#include + +namespace map2 { + +# define TEST_MAP(X) void X() { test::X >() ; } +# define TEST_MAP_NOLF(X) void X() { test_nolf::X >() ; } +# define TEST_MAP_EXTRACT(X) TEST_MAP(X) +# define TEST_MAP_NOLF_EXTRACT(X) TEST_MAP_NOLF(X) + + class Map_InsDel_Item_string: public CppUnitMini::TestCase + { + static size_t c_nMapSize; // map size + static size_t c_nThreadCount; // thread count + static size_t c_nGoalItem; + static size_t c_nAttemptCount; // count of SUCCESS insert/delete for each thread + static size_t c_nMaxLoadFactor;// maximum load factor + static bool c_bPrintGCState; + + typedef CppUnitMini::TestCase Base; + typedef std::string key_type; + typedef size_t value_type; + + const std::vector * m_parrString; + + template + class Inserter: public CppUnitMini::TestThread + { + Map& m_Map; + + virtual Inserter * clone() + { + return new Inserter( *this ); + } + public: + size_t m_nInsertSuccess; + size_t m_nInsertFailed; + + public: + Inserter( CppUnitMini::ThreadPool& pool, Map& rMap ) + : CppUnitMini::TestThread( pool ) + , m_Map( rMap ) + {} + Inserter( Inserter& src ) + : CppUnitMini::TestThread( src ) + , m_Map( src.m_Map ) + {} + + Map_InsDel_Item_string& getTest() + { + return reinterpret_cast( m_Pool.m_Test ); + } + + virtual void init() { cds::threading::Manager::attachThread() ; } + virtual void fini() { cds::threading::Manager::detachThread() ; } + + virtual void test() + { + Map& rMap = m_Map; + + m_nInsertSuccess = + m_nInsertFailed = 0; + + size_t nGoalItem = c_nGoalItem; + std::string strGoal = (*getTest().m_parrString)[nGoalItem]; + + for ( size_t nAttempt = 0; nAttempt < c_nAttemptCount; ) { + if ( rMap.insert( strGoal, nGoalItem )) { + ++m_nInsertSuccess; + ++nAttempt; + } + else + ++m_nInsertFailed; + } + } + }; + + template + class Deleter: public CppUnitMini::TestThread + { + Map& m_Map; + + struct erase_cleaner { + void operator ()(std::pair& val ) + { + val.second = 0; + } + // for boost::container::flat_map + void operator ()(std::pair< typename std::remove_const< typename Map::key_type >::type, typename Map::mapped_type>& val ) + { + val.second = 0; + } + // for BronsonAVLTreeMap + void operator()( typename Map::key_type const& /*key*/, typename Map::mapped_type& val ) + { + val = 0; + } + }; + + virtual Deleter * clone() + { + return new Deleter( *this ); + } + public: + size_t m_nDeleteSuccess; + size_t m_nDeleteFailed; + + public: + Deleter( CppUnitMini::ThreadPool& pool, Map& rMap ) + : CppUnitMini::TestThread( pool ) + , m_Map( rMap ) + {} + Deleter( Deleter& src ) + : CppUnitMini::TestThread( src ) + , m_Map( src.m_Map ) + {} + + Map_InsDel_Item_string& getTest() + { + return reinterpret_cast( m_Pool.m_Test ); + } + + virtual void init() { cds::threading::Manager::attachThread() ; } + virtual void fini() { cds::threading::Manager::detachThread() ; } + + virtual void test() + { + Map& rMap = m_Map; + + m_nDeleteSuccess = + m_nDeleteFailed = 0; + + size_t nGoalItem = c_nGoalItem; + std::string strGoal = (*getTest().m_parrString)[nGoalItem]; + + for ( size_t nAttempt = 0; nAttempt < c_nAttemptCount; ) { + if ( rMap.erase( strGoal, erase_cleaner() )) { + ++m_nDeleteSuccess; + ++nAttempt; + } + else + ++m_nDeleteFailed; + } + } + }; + + protected: + + template + void do_test( Map& testMap ) + { + typedef Inserter InserterThread; + typedef Deleter DeleterThread; + cds::OS::Timer timer; + + // Fill the map + CPPUNIT_MSG( " Fill map (" << c_nMapSize << " items)..."); + timer.reset(); + for ( size_t i = 0; i < c_nMapSize; ++i ) { + CPPUNIT_ASSERT_EX( testMap.insert( (*m_parrString)[i], i ), i ); + } + CPPUNIT_MSG( " Duration=" << timer.duration() ); + + CPPUNIT_MSG( " Insert/delete the key " << c_nGoalItem << " (" << c_nAttemptCount << " successful times)..."); + CppUnitMini::ThreadPool pool( *this ); + pool.add( new InserterThread( pool, testMap ), (c_nThreadCount + 1) / 2 ); + pool.add( new DeleterThread( pool, testMap ), (c_nThreadCount + 1) / 2 ); + pool.run(); + CPPUNIT_MSG( " Duration=" << pool.avgDuration() ); + + size_t nInsertSuccess = 0; + size_t nInsertFailed = 0; + size_t nDeleteSuccess = 0; + size_t nDeleteFailed = 0; + for ( CppUnitMini::ThreadPool::iterator it = pool.begin(); it != pool.end(); ++it ) { + InserterThread * pThread = dynamic_cast( *it ); + if ( pThread ) { + CPPUNIT_CHECK( pThread->m_nInsertSuccess == c_nAttemptCount ); + nInsertSuccess += pThread->m_nInsertSuccess; + nInsertFailed += pThread->m_nInsertFailed; + } + else { + DeleterThread * p = static_cast( *it ); + CPPUNIT_CHECK( p->m_nDeleteSuccess == c_nAttemptCount ); + nDeleteSuccess += p->m_nDeleteSuccess; + nDeleteFailed += p->m_nDeleteFailed; + } + } + CPPUNIT_CHECK_EX( nInsertSuccess == nDeleteSuccess, "nInsertSuccess=" << nInsertSuccess << ", nDeleteSuccess=" << nDeleteSuccess ); + CPPUNIT_MSG( " Totals: Ins fail=" << nInsertFailed << " Del fail=" << nDeleteFailed ); + + // Check if the map contains all items + CPPUNIT_MSG( " Check if the map contains all items" ); + timer.reset(); + for ( size_t i = 0; i < c_nMapSize; ++i ) { + CPPUNIT_CHECK_EX( testMap.find( (*m_parrString)[i] ), "Key \"" << (*m_parrString)[i] << "\" not found" ); + } + CPPUNIT_MSG( " Duration=" << timer.duration() ); + + check_before_cleanup( testMap ); + + testMap.clear(); + additional_check( testMap ); + print_stat( testMap ); + additional_cleanup( testMap ); + } + + template + void test() + { + m_parrString = &CppUnitMini::TestCase::getTestStrings(); + if ( c_nMapSize > m_parrString->size() ) + c_nMapSize = m_parrString->size(); + if ( c_nGoalItem > m_parrString->size() ) + c_nGoalItem = m_parrString->size() / 2; + + CPPUNIT_MSG( "Thread count= " << c_nThreadCount + << " pass count=" << c_nAttemptCount + << " map size=" << c_nMapSize + ); + + for ( size_t nLoadFactor = 1; nLoadFactor <= c_nMaxLoadFactor; nLoadFactor *= 2 ) { + CPPUNIT_MSG( "Load factor=" << nLoadFactor ); + Map testMap( c_nMapSize, nLoadFactor ); + do_test( testMap ); + if ( c_bPrintGCState ) + print_gc_state(); + } + } + + template + void test_nolf() + { + m_parrString = &CppUnitMini::TestCase::getTestStrings(); + if ( c_nMapSize > m_parrString->size() ) + c_nMapSize = m_parrString->size(); + if ( c_nGoalItem > m_parrString->size() ) + c_nGoalItem = m_parrString->size() / 2; + + CPPUNIT_MSG( "Thread count= " << c_nThreadCount + << " pass count=" << c_nAttemptCount + << " map size=" << c_nMapSize + ); + + Map testMap; + do_test( testMap ); + if ( c_bPrintGCState ) + print_gc_state(); + } + + void setUpParams( const CppUnitMini::TestCfg& cfg ); + + void run_MichaelMap(const char *in_name, bool invert = false); + void run_SplitList(const char *in_name, bool invert = false); + void run_SkipListMap(const char *in_name, bool invert = false); + void run_StripedMap(const char *in_name, bool invert = false); + void run_RefinableMap(const char *in_name, bool invert = false); + void run_CuckooMap(const char *in_name, bool invert = false); + void run_EllenBinTreeMap(const char *in_name, bool invert = false); + void run_BronsonAVLTreeMap(const char *in_name, bool invert = false); + + virtual void myRun(const char *in_name, bool invert = false); + +# include "map2/map_defs.h" + CDSUNIT_DECLARE_MichaelMap + CDSUNIT_DECLARE_SplitList + CDSUNIT_DECLARE_SkipListMap + CDSUNIT_DECLARE_EllenBinTreeMap + CDSUNIT_DECLARE_BronsonAVLTreeMap + CDSUNIT_DECLARE_StripedMap + CDSUNIT_DECLARE_RefinableMap + CDSUNIT_DECLARE_CuckooMap + //CDSUNIT_DECLARE_StdMap // very slow! + }; +} // namespace map2 diff --git a/tests/unit/map2/map_insdel_item_string_bronsonavltree.cpp b/tests/unit/map2/map_insdel_item_string_bronsonavltree.cpp new file mode 100644 index 00000000..57c5e82b --- /dev/null +++ b/tests/unit/map2/map_insdel_item_string_bronsonavltree.cpp @@ -0,0 +1,9 @@ +//$$CDS-header$$ + +#include "map2/map_insdel_item_string.h" + +namespace map2 { + CPPUNIT_TEST_SUITE_PART( Map_InsDel_Item_string, run_BronsonAVLTreeMap ) + CDSUNIT_TEST_BronsonAVLTreeMap + CPPUNIT_TEST_SUITE_END_PART() +} // namespace map2 diff --git a/tests/unit/map2/map_insdel_item_string_cuckoo.cpp b/tests/unit/map2/map_insdel_item_string_cuckoo.cpp new file mode 100644 index 00000000..a7ec0dd0 --- /dev/null +++ b/tests/unit/map2/map_insdel_item_string_cuckoo.cpp @@ -0,0 +1,9 @@ +//$$CDS-header$$ + +#include "map2/map_insdel_item_string.h" + +namespace map2 { + CPPUNIT_TEST_SUITE_PART( Map_InsDel_Item_string, run_CuckooMap ) + CDSUNIT_TEST_CuckooMap + CPPUNIT_TEST_SUITE_END_PART() +} // namespace map2 diff --git a/tests/unit/map2/map_insdel_item_string_ellentree.cpp b/tests/unit/map2/map_insdel_item_string_ellentree.cpp new file mode 100644 index 00000000..c2fff3fc --- /dev/null +++ b/tests/unit/map2/map_insdel_item_string_ellentree.cpp @@ -0,0 +1,9 @@ +//$$CDS-header$$ + +#include "map2/map_insdel_item_string.h" + +namespace map2 { + CPPUNIT_TEST_SUITE_PART( Map_InsDel_Item_string, run_EllenBinTreeMap ) + CDSUNIT_TEST_EllenBinTreeMap + CPPUNIT_TEST_SUITE_END_PART() +} // namespace map2 diff --git a/tests/unit/map2/map_insdel_item_string_michael.cpp b/tests/unit/map2/map_insdel_item_string_michael.cpp new file mode 100644 index 00000000..e2a17a29 --- /dev/null +++ b/tests/unit/map2/map_insdel_item_string_michael.cpp @@ -0,0 +1,9 @@ +//$$CDS-header$$ + +#include "map2/map_insdel_item_string.h" + +namespace map2 { + CPPUNIT_TEST_SUITE_PART( Map_InsDel_Item_string, run_MichaelMap ) + CDSUNIT_TEST_MichaelMap + CPPUNIT_TEST_SUITE_END_PART() +} // namespace map2 diff --git a/tests/unit/map2/map_insdel_item_string_refinable.cpp b/tests/unit/map2/map_insdel_item_string_refinable.cpp new file mode 100644 index 00000000..2d5819c7 --- /dev/null +++ b/tests/unit/map2/map_insdel_item_string_refinable.cpp @@ -0,0 +1,9 @@ +//$$CDS-header$$ + +#include "map2/map_insdel_item_string.h" + +namespace map2 { + CPPUNIT_TEST_SUITE_PART( Map_InsDel_Item_string, run_RefinableMap ) + CDSUNIT_TEST_RefinableMap + CPPUNIT_TEST_SUITE_END_PART() +} // namespace map2 diff --git a/tests/unit/map2/map_insdel_item_string_skip.cpp b/tests/unit/map2/map_insdel_item_string_skip.cpp new file mode 100644 index 00000000..4a3fa18a --- /dev/null +++ b/tests/unit/map2/map_insdel_item_string_skip.cpp @@ -0,0 +1,9 @@ +//$$CDS-header$$ + +#include "map2/map_insdel_item_string.h" + +namespace map2 { + CPPUNIT_TEST_SUITE_PART( Map_InsDel_Item_string, run_SkipListMap ) + CDSUNIT_TEST_SkipListMap + CPPUNIT_TEST_SUITE_END_PART() +} // namespace map2 diff --git a/tests/unit/map2/map_insdel_item_string_split.cpp b/tests/unit/map2/map_insdel_item_string_split.cpp new file mode 100644 index 00000000..ebb2bf00 --- /dev/null +++ b/tests/unit/map2/map_insdel_item_string_split.cpp @@ -0,0 +1,9 @@ +//$$CDS-header$$ + +#include "map2/map_insdel_item_string.h" + +namespace map2 { + CPPUNIT_TEST_SUITE_PART( Map_InsDel_Item_string, run_SplitList ) + CDSUNIT_TEST_SplitList + CPPUNIT_TEST_SUITE_END_PART() +} // namespace map2 diff --git a/tests/unit/map2/map_insdel_item_string_striped.cpp b/tests/unit/map2/map_insdel_item_string_striped.cpp new file mode 100644 index 00000000..be0ba3df --- /dev/null +++ b/tests/unit/map2/map_insdel_item_string_striped.cpp @@ -0,0 +1,9 @@ +//$$CDS-header$$ + +#include "map2/map_insdel_item_string.h" + +namespace map2 { + CPPUNIT_TEST_SUITE_PART( Map_InsDel_Item_string, run_StripedMap ) + CDSUNIT_TEST_StripedMap + CPPUNIT_TEST_SUITE_END_PART() +} // namespace map2 -- 2.34.1