From: khizmax Date: Wed, 25 Mar 2015 12:59:05 +0000 (+0300) Subject: Splitted up map_insdelfind test to reduce compiling time and memory requirements X-Git-Tag: v2.1.0~296^2~7 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=382475a8db4da240ddcdb3ddaf916063d3e41060;p=libcds.git Splitted up map_insdelfind test to reduce compiling time and memory requirements --- diff --git a/projects/Win/vc12/unit-map-find.vcxproj.filters b/projects/Win/vc12/unit-map-find.vcxproj.filters new file mode 100644 index 00000000..7bdd4a8f --- /dev/null +++ b/projects/Win/vc12/unit-map-find.vcxproj.filters @@ -0,0 +1,117 @@ + + + + + map_find_int + + + map_find_int + + + map_find_int + + + map_find_int + + + map_find_int + + + map_find_int + + + map_find_int + + + map_find_int + + + map_find_int + + + map_find_int + + + map_find_string + + + map_find_string + + + map_find_string + + + map_find_string + + + map_find_string + + + map_find_string + + + map_find_string + + + map_find_string + + + map_find_string + + + map_find_string + + + map_insfind_int + + + map_insfind_int + + + map_insfind_int + + + map_insfind_int + + + map_insfind_int + + + map_insfind_int + + + map_insfind_int + + + map_insfind_int + + + map_insfind_int + + + map_insfind_int + + + + + map_find_int + + + map_find_string + + + map_insfind_int + + + + + {05793356-5544-4e12-893f-5761dea6536e} + + + {c6ad8146-72e2-473c-aa04-3db455858146} + + + {ba26fa2b-d618-4dd8-97d6-7dc874d9acf4} + + + \ No newline at end of file diff --git a/projects/Win/vc12/unit-map-insdel.vcxproj b/projects/Win/vc12/unit-map-insdel.vcxproj index efb99771..2ce3da97 100644 --- a/projects/Win/vc12/unit-map-insdel.vcxproj +++ b/projects/Win/vc12/unit-map-insdel.vcxproj @@ -44,6 +44,15 @@ + + + + + + + + + @@ -76,6 +85,7 @@ + diff --git a/projects/Win/vc12/unit-map-insdel.vcxproj.filters b/projects/Win/vc12/unit-map-insdel.vcxproj.filters new file mode 100644 index 00000000..a4347fb3 --- /dev/null +++ b/projects/Win/vc12/unit-map-insdel.vcxproj.filters @@ -0,0 +1,159 @@ + + + + + map_insdel_func + + + map_insdel_func + + + map_insdel_func + + + map_insdel_func + + + map_insdel_func + + + map_insdel_func + + + map_insdel_func + + + map_insdel_func + + + map_insdel_func + + + map_insdel_int + + + map_insdel_int + + + map_insdel_int + + + map_insdel_int + + + map_insdel_int + + + map_insdel_int + + + map_insdel_int + + + map_insdel_int + + + map_insdel_int + + + map_insdel_item_int + + + map_insdel_item_string + + + map_insdel_string + + + map_insdel_string + + + map_insdel_string + + + map_insdel_string + + + map_insdel_string + + + map_insdel_string + + + map_insdel_string + + + map_insdel_string + + + map_insdel_string + + + map_insdel_string + + + map_insdelfind + + + map_insdelfind + + + map_insdelfind + + + map_insdelfind + + + map_insdelfind + + + map_insdelfind + + + map_insdelfind + + + map_insdelfind + + + map_insdelfind + + + map_insdelfind + + + + + {7cb9e730-e4e0-4648-96f1-e1dbf119756e} + + + {55aed984-fed9-4007-9ad3-59bec69befe8} + + + {8e7ec24b-8a28-4503-8514-4593923e3451} + + + {e7eec6ab-d1a8-4b59-afe9-b98e1b133d73} + + + {f613f4ac-8b0f-4a85-81be-d243141b3ce3} + + + {9172b0cf-89b6-44eb-bddd-1c59d254bff8} + + + + + map_insdel_func + + + map_insdel_int + + + map_insdel_string + + + map_insdelfind + + + \ No newline at end of file diff --git a/projects/Win/vc12/unit-set-insdel.vcxproj.filters b/projects/Win/vc12/unit-set-insdel.vcxproj.filters new file mode 100644 index 00000000..476f031c --- /dev/null +++ b/projects/Win/vc12/unit-set-insdel.vcxproj.filters @@ -0,0 +1,38 @@ + + + + + + + set_insdel_func + + + set_insdel_func + + + set_insdel_func + + + set_insdel_func + + + set_insdel_func + + + set_insdel_func + + + set_insdel_func + + + + + {cbe5ede5-77ea-49bb-be6a-16d30d8416f7} + + + + + set_insdel_func + + + \ No newline at end of file diff --git a/projects/source.unit.map.mk b/projects/source.unit.map.mk index 7fc6d53b..622ac5a8 100644 --- a/projects/source.unit.map.mk +++ b/projects/source.unit.map.mk @@ -62,6 +62,15 @@ CDSUNIT_MAP_SOURCES := \ 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 \ + tests/unit/map2/map_insdelfind_skip.cpp \ + tests/unit/map2/map_insdelfind_ellentree.cpp \ + tests/unit/map2/map_insdelfind_bronsonavltree.cpp \ + tests/unit/map2/map_insdelfind_striped.cpp \ + tests/unit/map2/map_insdelfind_refinable.cpp \ + tests/unit/map2/map_insdelfind_cuckoo.cpp \ + tests/unit/map2/map_insdelfind_std.cpp \ tests/unit/map2/map_delodd.cpp \ tests/unit/map2/map_delodd_michael.cpp \ tests/unit/map2/map_delodd_bronsonavltree.cpp \ diff --git a/tests/unit/map2/map_insdelfind.cpp b/tests/unit/map2/map_insdelfind.cpp index 83965cb8..28df1fac 100644 --- a/tests/unit/map2/map_insdelfind.cpp +++ b/tests/unit/map2/map_insdelfind.cpp @@ -1,278 +1,59 @@ //$$CDS-header$$ -#include "map2/map_types.h" -#include "cppunit/thread.h" -#include // random_shuffle -#include +#include "map2/map_insdelfind.h" namespace map2 { + CPPUNIT_TEST_SUITE_REGISTRATION( Map_InsDelFind ); -# 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_InsDelFind::c_nInitialMapSize = 500000; + size_t Map_InsDelFind::c_nThreadCount = 8; + size_t Map_InsDelFind::c_nMaxLoadFactor = 8; + unsigned int Map_InsDelFind::c_nInsertPercentage = 5; + unsigned int Map_InsDelFind::c_nDeletePercentage = 5; + unsigned int Map_InsDelFind::c_nDuration = 30; + bool Map_InsDelFind::c_bPrintGCState = true; - namespace { - static size_t c_nInitialMapSize = 500000 ; // initial map size - static size_t c_nThreadCount = 8 ; // thread count - static size_t c_nMaxLoadFactor = 8 ; // maximum load factor - static unsigned int c_nInsertPercentage = 5; - static unsigned int c_nDeletePercentage = 5; - static unsigned int c_nDuration = 30 ; // test duration, seconds - static bool c_bPrintGCState = true; + void Map_InsDelFind::setUpParams( const CppUnitMini::TestCfg& cfg ) + { + c_nInitialMapSize = cfg.getSizeT("InitialMapSize", c_nInitialMapSize ); + c_nThreadCount = cfg.getSizeT("ThreadCount", c_nThreadCount ); + c_nMaxLoadFactor = cfg.getSizeT("MaxLoadFactor", c_nMaxLoadFactor ); + c_nInsertPercentage = cfg.getUInt("InsertPercentage", c_nInsertPercentage ); + c_nDeletePercentage = cfg.getUInt("DeletePercentage", c_nDeletePercentage ); + c_nDuration = cfg.getUInt("Duration", c_nDuration ); + c_bPrintGCState = cfg.getBool("PrintGCStateFlag", c_bPrintGCState ); + + if ( c_nThreadCount == 0 ) + c_nThreadCount = cds::OS::topology::processor_count() * 2; + + CPPUNIT_ASSERT( c_nInsertPercentage + c_nDeletePercentage <= 100 ); + + actions * pFirst = m_arrShuffle; + actions * pLast = m_arrShuffle + c_nInsertPercentage; + std::fill( pFirst, pLast, do_insert ); + pFirst = pLast; + pLast += c_nDeletePercentage; + std::fill( pFirst, pLast, do_delete ); + pFirst = pLast; + pLast = m_arrShuffle + sizeof(m_arrShuffle)/sizeof(m_arrShuffle[0]); + std::fill( pFirst, pLast, do_find ); + std::random_shuffle( m_arrShuffle, pLast ); } - class Map_InsDelFind: public CppUnitMini::TestCase + void Map_InsDelFind::myRun(const char *in_name, bool invert /*= false*/) { - public: - enum actions - { - do_find, - do_insert, - do_delete - }; - static const unsigned int c_nShuffleSize = 100; - actions m_arrShuffle[c_nShuffleSize]; - - protected: - typedef size_t key_type; - typedef size_t value_type; - - template - class WorkThread: public CppUnitMini::TestThread - { - MAP& m_Map; - - virtual WorkThread * clone() - { - return new WorkThread( *this ); - } - public: - size_t m_nInsertSuccess; - size_t m_nInsertFailed; - size_t m_nDeleteSuccess; - size_t m_nDeleteFailed; - size_t m_nFindSuccess; - size_t m_nFindFailed; - - public: - WorkThread( CppUnitMini::ThreadPool& pool, MAP& rMap ) - : CppUnitMini::TestThread( pool ) - , m_Map( rMap ) - {} - WorkThread( WorkThread& src ) - : CppUnitMini::TestThread( src ) - , m_Map( src.m_Map ) - {} - - Map_InsDelFind& 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 = - m_nDeleteSuccess = - m_nDeleteFailed = - m_nFindSuccess = - m_nFindFailed = 0; - - actions * pAct = getTest().m_arrShuffle; - unsigned int i = 0; - size_t const nNormalize = size_t(-1) / (c_nInitialMapSize * 2); - - size_t nRand = 0; - while ( !time_elapsed() ) { - nRand = cds::bitop::RandXorShift(nRand); - size_t n = nRand / nNormalize; - switch ( pAct[i] ) { - case do_find: - if ( rMap.find( n )) - ++m_nFindSuccess; - else - ++m_nFindFailed; - break; - case do_insert: - if ( rMap.insert( n, n )) - ++m_nInsertSuccess; - else - ++m_nInsertFailed; - break; - case do_delete: - if ( rMap.erase( n )) - ++m_nDeleteSuccess; - else - ++m_nDeleteFailed; - break; - } - - if ( ++i >= c_nShuffleSize ) - i = 0; - } - } - }; - - protected: - template - void do_test( MAP& testMap ) - { - typedef WorkThread work_thread; - cds::OS::Timer timer; - - // fill map - only odd number - { - std::vector arr; - arr.reserve( c_nInitialMapSize ); - for ( size_t i = 0; i < c_nInitialMapSize; ++i ) - arr.push_back( i * 2 + 1); - std::random_shuffle( arr.begin(), arr.end() ); - for ( size_t i = 0; i < c_nInitialMapSize; ++i ) - testMap.insert( arr[i], arr[i] ); - } - CPPUNIT_MSG( " Insert " << c_nInitialMapSize << " items time (single-threaded)=" << timer.duration() ); - - timer.reset(); - CppUnitMini::ThreadPool pool( *this ); - pool.add( new work_thread( pool, testMap ), c_nThreadCount ); - pool.run( c_nDuration ); - //CPPUNIT_MSG( " Duration=" << pool.avgDuration() ); - - size_t nInsertSuccess = 0; - size_t nInsertFailed = 0; - size_t nDeleteSuccess = 0; - size_t nDeleteFailed = 0; - size_t nFindSuccess = 0; - size_t nFindFailed = 0; - for ( CppUnitMini::ThreadPool::iterator it = pool.begin(); it != pool.end(); ++it ) { - work_thread * pThread = static_cast( *it ); - assert( pThread != nullptr ); - nInsertSuccess += pThread->m_nInsertSuccess; - nInsertFailed += pThread->m_nInsertFailed; - nDeleteSuccess += pThread->m_nDeleteSuccess; - nDeleteFailed += pThread->m_nDeleteFailed; - nFindSuccess += pThread->m_nFindSuccess; - nFindFailed += pThread->m_nFindFailed; - } - - size_t nTotalOps = nInsertSuccess + nInsertFailed + nDeleteSuccess + nDeleteFailed + nFindSuccess + nFindFailed; - - CPPUNIT_MSG( " Totals (success/failed): \n\t" - << " Insert=" << nInsertSuccess << '/' << nInsertFailed << "\n\t" - << " Delete=" << nDeleteSuccess << '/' << nDeleteFailed << "\n\t" - << " Find=" << nFindSuccess << '/' << nFindFailed << "\n\t" - << " Speed=" << (nFindSuccess + nFindFailed) / c_nDuration << " find/sec\n\t" - << " " << (nInsertSuccess + nDeleteSuccess) / c_nDuration << " modify/sec\n\t" - << " Total ops=" << nTotalOps << "\n\t" - << " speed=" << nTotalOps / c_nDuration << " ops/sec\n\t" - << " Map size=" << testMap.size() - ); - - - check_before_cleanup( testMap ); - - CPPUNIT_MSG( " Clear map (single-threaded)..." ); - timer.reset(); - testMap.clear(); - CPPUNIT_MSG( " Duration=" << timer.duration() ); - CPPUNIT_ASSERT_EX( testMap.empty(), ((long long) testMap.size()) ); - - additional_check( testMap ); - print_stat( testMap ); - additional_cleanup( testMap ); - } - - template - void test() - { - CPPUNIT_MSG( "Thread count=" << c_nThreadCount - << " initial map size=" << c_nInitialMapSize - << " insert=" << c_nInsertPercentage << '%' - << " delete=" << c_nDeletePercentage << '%' - << " duration=" << c_nDuration << "s" - ); - - for ( size_t nLoadFactor = 1; nLoadFactor <= c_nMaxLoadFactor; nLoadFactor *= 2 ) { - CPPUNIT_MSG( "Load factor=" << nLoadFactor ); - MAP testMap( c_nInitialMapSize, nLoadFactor ); - do_test( testMap ); - if ( c_bPrintGCState ) - print_gc_state(); - } - - } - - template - void test_nolf() - { - CPPUNIT_MSG( "Thread count=" << c_nThreadCount - << " initial map size=" << c_nInitialMapSize - << " insert=" << c_nInsertPercentage << '%' - << " delete=" << c_nDeletePercentage << '%' - << " duration=" << c_nDuration << "s" - ); - - MAP testMap; - do_test( testMap ); - if ( c_bPrintGCState ) - print_gc_state(); - } - - void setUpParams( const CppUnitMini::TestCfg& cfg ) { - c_nInitialMapSize = cfg.getULong("InitialMapSize", 500000 ); - c_nThreadCount = cfg.getULong("ThreadCount", 8 ); - c_nMaxLoadFactor = cfg.getULong("MaxLoadFactor", 8 ); - c_nInsertPercentage = cfg.getUInt("InsertPercentage", 5 ); - c_nDeletePercentage = cfg.getUInt("DeletePercentage", 5 ); - c_nDuration = cfg.getUInt("Duration", 30 ); - c_bPrintGCState = cfg.getBool("PrintGCStateFlag", true ); - - if ( c_nThreadCount == 0 ) - c_nThreadCount = cds::OS::topology::processor_count() * 2; - - CPPUNIT_ASSERT( c_nInsertPercentage + c_nDeletePercentage <= 100 ); - - actions * pFirst = m_arrShuffle; - actions * pLast = m_arrShuffle + c_nInsertPercentage; - std::fill( pFirst, pLast, do_insert ); - pFirst = pLast; - pLast += c_nDeletePercentage; - std::fill( pFirst, pLast, do_delete ); - pFirst = pLast; - pLast = m_arrShuffle + sizeof(m_arrShuffle)/sizeof(m_arrShuffle[0]); - std::fill( pFirst, pLast, do_find ); - std::random_shuffle( m_arrShuffle, pLast ); - } - -# 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_InsDelFind ) - 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 - CPPUNIT_TEST_SUITE_END() - }; - - CPPUNIT_TEST_SUITE_REGISTRATION( Map_InsDelFind ); + setUpParams( m_Cfg.get( "Map_InsDelFind" )); + + 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); + run_StdMap(in_name, invert); + + endTestCase(); + } } // namespace map2 diff --git a/tests/unit/map2/map_insdelfind.h b/tests/unit/map2/map_insdelfind.h new file mode 100644 index 00000000..c5e36f1a --- /dev/null +++ b/tests/unit/map2/map_insdelfind.h @@ -0,0 +1,251 @@ +//$$CDS-header$$ + +#include "map2/map_types.h" +#include "cppunit/thread.h" +#include // random_shuffle +#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_InsDelFind: public CppUnitMini::TestCase + { + static size_t c_nInitialMapSize; // initial map size + static size_t c_nThreadCount; // thread count + static size_t c_nMaxLoadFactor; // maximum load factor + static unsigned int c_nInsertPercentage; + static unsigned int c_nDeletePercentage; + static unsigned int c_nDuration; // test duration, seconds + static bool c_bPrintGCState; + + public: + enum actions + { + do_find, + do_insert, + do_delete + }; + static const unsigned int c_nShuffleSize = 100; + actions m_arrShuffle[c_nShuffleSize]; + + protected: + typedef CppUnitMini::TestCase Base; + typedef size_t key_type; + typedef size_t value_type; + + template + class WorkThread: public CppUnitMini::TestThread + { + MAP& m_Map; + + virtual WorkThread * clone() + { + return new WorkThread( *this ); + } + public: + size_t m_nInsertSuccess; + size_t m_nInsertFailed; + size_t m_nDeleteSuccess; + size_t m_nDeleteFailed; + size_t m_nFindSuccess; + size_t m_nFindFailed; + + public: + WorkThread( CppUnitMini::ThreadPool& pool, MAP& rMap ) + : CppUnitMini::TestThread( pool ) + , m_Map( rMap ) + {} + WorkThread( WorkThread& src ) + : CppUnitMini::TestThread( src ) + , m_Map( src.m_Map ) + {} + + Map_InsDelFind& 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 = + m_nDeleteSuccess = + m_nDeleteFailed = + m_nFindSuccess = + m_nFindFailed = 0; + + actions * pAct = getTest().m_arrShuffle; + unsigned int i = 0; + size_t const nNormalize = size_t(-1) / (c_nInitialMapSize * 2); + + size_t nRand = 0; + while ( !time_elapsed() ) { + nRand = cds::bitop::RandXorShift(nRand); + size_t n = nRand / nNormalize; + switch ( pAct[i] ) { + case do_find: + if ( rMap.find( n )) + ++m_nFindSuccess; + else + ++m_nFindFailed; + break; + case do_insert: + if ( rMap.insert( n, n )) + ++m_nInsertSuccess; + else + ++m_nInsertFailed; + break; + case do_delete: + if ( rMap.erase( n )) + ++m_nDeleteSuccess; + else + ++m_nDeleteFailed; + break; + } + + if ( ++i >= c_nShuffleSize ) + i = 0; + } + } + }; + + protected: + template + void do_test( MAP& testMap ) + { + typedef WorkThread work_thread; + cds::OS::Timer timer; + + // fill map - only odd number + { + std::vector arr; + arr.reserve( c_nInitialMapSize ); + for ( size_t i = 0; i < c_nInitialMapSize; ++i ) + arr.push_back( i * 2 + 1); + std::random_shuffle( arr.begin(), arr.end() ); + for ( size_t i = 0; i < c_nInitialMapSize; ++i ) + testMap.insert( arr[i], arr[i] ); + } + CPPUNIT_MSG( " Insert " << c_nInitialMapSize << " items time (single-threaded)=" << timer.duration() ); + + timer.reset(); + CppUnitMini::ThreadPool pool( *this ); + pool.add( new work_thread( pool, testMap ), c_nThreadCount ); + pool.run( c_nDuration ); + //CPPUNIT_MSG( " Duration=" << pool.avgDuration() ); + + size_t nInsertSuccess = 0; + size_t nInsertFailed = 0; + size_t nDeleteSuccess = 0; + size_t nDeleteFailed = 0; + size_t nFindSuccess = 0; + size_t nFindFailed = 0; + for ( CppUnitMini::ThreadPool::iterator it = pool.begin(); it != pool.end(); ++it ) { + work_thread * pThread = static_cast( *it ); + assert( pThread != nullptr ); + nInsertSuccess += pThread->m_nInsertSuccess; + nInsertFailed += pThread->m_nInsertFailed; + nDeleteSuccess += pThread->m_nDeleteSuccess; + nDeleteFailed += pThread->m_nDeleteFailed; + nFindSuccess += pThread->m_nFindSuccess; + nFindFailed += pThread->m_nFindFailed; + } + + size_t nTotalOps = nInsertSuccess + nInsertFailed + nDeleteSuccess + nDeleteFailed + nFindSuccess + nFindFailed; + + CPPUNIT_MSG( " Totals (success/failed): \n\t" + << " Insert=" << nInsertSuccess << '/' << nInsertFailed << "\n\t" + << " Delete=" << nDeleteSuccess << '/' << nDeleteFailed << "\n\t" + << " Find=" << nFindSuccess << '/' << nFindFailed << "\n\t" + << " Speed=" << (nFindSuccess + nFindFailed) / c_nDuration << " find/sec\n\t" + << " " << (nInsertSuccess + nDeleteSuccess) / c_nDuration << " modify/sec\n\t" + << " Total ops=" << nTotalOps << "\n\t" + << " speed=" << nTotalOps / c_nDuration << " ops/sec\n\t" + << " Map size=" << testMap.size() + ); + + + check_before_cleanup( testMap ); + + CPPUNIT_MSG( " Clear map (single-threaded)..." ); + timer.reset(); + testMap.clear(); + CPPUNIT_MSG( " Duration=" << timer.duration() ); + CPPUNIT_ASSERT_EX( testMap.empty(), ((long long) testMap.size()) ); + + additional_check( testMap ); + print_stat( testMap ); + additional_cleanup( testMap ); + } + + template + void test() + { + CPPUNIT_MSG( "Thread count=" << c_nThreadCount + << " initial map size=" << c_nInitialMapSize + << " insert=" << c_nInsertPercentage << '%' + << " delete=" << c_nDeletePercentage << '%' + << " duration=" << c_nDuration << "s" + ); + + for ( size_t nLoadFactor = 1; nLoadFactor <= c_nMaxLoadFactor; nLoadFactor *= 2 ) { + CPPUNIT_MSG( "Load factor=" << nLoadFactor ); + MAP testMap( c_nInitialMapSize, nLoadFactor ); + do_test( testMap ); + if ( c_bPrintGCState ) + print_gc_state(); + } + + } + + template + void test_nolf() + { + CPPUNIT_MSG( "Thread count=" << c_nThreadCount + << " initial map size=" << c_nInitialMapSize + << " insert=" << c_nInsertPercentage << '%' + << " delete=" << c_nDeletePercentage << '%' + << " duration=" << c_nDuration << "s" + ); + + 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_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_SkipListMap(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); + void run_StdMap(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 + }; +} // namespace map2 diff --git a/tests/unit/map2/map_insdelfind_bronsonavltree.cpp b/tests/unit/map2/map_insdelfind_bronsonavltree.cpp new file mode 100644 index 00000000..7d1731e8 --- /dev/null +++ b/tests/unit/map2/map_insdelfind_bronsonavltree.cpp @@ -0,0 +1,9 @@ +//$$CDS-header$$ + +#include "map2/map_insdelfind.h" + +namespace map2 { + CPPUNIT_TEST_SUITE_PART( Map_InsDelFind, run_BronsonAVLTreeMap ) + CDSUNIT_TEST_BronsonAVLTreeMap + CPPUNIT_TEST_SUITE_END_PART() +} // namespace map2 diff --git a/tests/unit/map2/map_insdelfind_cuckoo.cpp b/tests/unit/map2/map_insdelfind_cuckoo.cpp new file mode 100644 index 00000000..10e17494 --- /dev/null +++ b/tests/unit/map2/map_insdelfind_cuckoo.cpp @@ -0,0 +1,9 @@ +//$$CDS-header$$ + +#include "map2/map_insdelfind.h" + +namespace map2 { + CPPUNIT_TEST_SUITE_PART( Map_InsDelFind, run_CuckooMap ) + CDSUNIT_TEST_CuckooMap + CPPUNIT_TEST_SUITE_END_PART() +} // namespace map2 diff --git a/tests/unit/map2/map_insdelfind_ellentree.cpp b/tests/unit/map2/map_insdelfind_ellentree.cpp new file mode 100644 index 00000000..22b66951 --- /dev/null +++ b/tests/unit/map2/map_insdelfind_ellentree.cpp @@ -0,0 +1,9 @@ +//$$CDS-header$$ + +#include "map2/map_insdelfind.h" + +namespace map2 { + CPPUNIT_TEST_SUITE_PART( Map_InsDelFind, run_EllenBinTreeMap ) + CDSUNIT_TEST_EllenBinTreeMap + CPPUNIT_TEST_SUITE_END_PART() +} // namespace map2 diff --git a/tests/unit/map2/map_insdelfind_michael.cpp b/tests/unit/map2/map_insdelfind_michael.cpp new file mode 100644 index 00000000..dbc0487b --- /dev/null +++ b/tests/unit/map2/map_insdelfind_michael.cpp @@ -0,0 +1,9 @@ +//$$CDS-header$$ + +#include "map2/map_insdelfind.h" + +namespace map2 { + CPPUNIT_TEST_SUITE_PART( Map_InsDelFind, run_MichaelMap ) + CDSUNIT_TEST_MichaelMap + CPPUNIT_TEST_SUITE_END_PART() +} // namespace map2 diff --git a/tests/unit/map2/map_insdelfind_refinable.cpp b/tests/unit/map2/map_insdelfind_refinable.cpp new file mode 100644 index 00000000..a1bbde45 --- /dev/null +++ b/tests/unit/map2/map_insdelfind_refinable.cpp @@ -0,0 +1,9 @@ +//$$CDS-header$$ + +#include "map2/map_insdelfind.h" + +namespace map2 { + CPPUNIT_TEST_SUITE_PART( Map_InsDelFind, run_RefinableMap ) + CDSUNIT_TEST_RefinableMap + CPPUNIT_TEST_SUITE_END_PART() +} // namespace map2 diff --git a/tests/unit/map2/map_insdelfind_skip.cpp b/tests/unit/map2/map_insdelfind_skip.cpp new file mode 100644 index 00000000..861ffaef --- /dev/null +++ b/tests/unit/map2/map_insdelfind_skip.cpp @@ -0,0 +1,9 @@ +//$$CDS-header$$ + +#include "map2/map_insdelfind.h" + +namespace map2 { + CPPUNIT_TEST_SUITE_PART( Map_InsDelFind, run_SkipListMap ) + CDSUNIT_TEST_SkipListMap + CPPUNIT_TEST_SUITE_END_PART() +} // namespace map2 diff --git a/tests/unit/map2/map_insdelfind_split.cpp b/tests/unit/map2/map_insdelfind_split.cpp new file mode 100644 index 00000000..c5b3c7c1 --- /dev/null +++ b/tests/unit/map2/map_insdelfind_split.cpp @@ -0,0 +1,9 @@ +//$$CDS-header$$ + +#include "map2/map_insdelfind.h" + +namespace map2 { + CPPUNIT_TEST_SUITE_PART( Map_InsDelFind, run_SplitList ) + CDSUNIT_TEST_SplitList + CPPUNIT_TEST_SUITE_END_PART() +} // namespace map2 diff --git a/tests/unit/map2/map_insdelfind_std.cpp b/tests/unit/map2/map_insdelfind_std.cpp new file mode 100644 index 00000000..b608a9bb --- /dev/null +++ b/tests/unit/map2/map_insdelfind_std.cpp @@ -0,0 +1,9 @@ +//$$CDS-header$$ + +#include "map2/map_insdelfind.h" + +namespace map2 { + CPPUNIT_TEST_SUITE_PART( Map_InsDelFind, run_StdMap ) + CDSUNIT_TEST_StdMap + CPPUNIT_TEST_SUITE_END_PART() +} // namespace map2 diff --git a/tests/unit/map2/map_insdelfind_striped.cpp b/tests/unit/map2/map_insdelfind_striped.cpp new file mode 100644 index 00000000..9384ffd8 --- /dev/null +++ b/tests/unit/map2/map_insdelfind_striped.cpp @@ -0,0 +1,9 @@ +//$$CDS-header$$ + +#include "map2/map_insdelfind.h" + +namespace map2 { + CPPUNIT_TEST_SUITE_PART( Map_InsDelFind, run_StripedMap ) + CDSUNIT_TEST_StripedMap + CPPUNIT_TEST_SUITE_END_PART() +} // namespace map2