From: khizmax Date: Thu, 6 Oct 2016 16:56:04 +0000 (+0300) Subject: Improved test conditions X-Git-Tag: v2.2.0~97 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=libcds.git;a=commitdiff_plain;h=62ebcd28a62b0c6a414a6b4d27b9fa3098bf5006 Improved test conditions --- diff --git a/projects/Win/vc14/stress-set-insdel_func.vcxproj.filters b/projects/Win/vc14/stress-set-insdel_func.vcxproj.filters index 39278ed0..982c2cbb 100644 --- a/projects/Win/vc14/stress-set-insdel_func.vcxproj.filters +++ b/projects/Win/vc14/stress-set-insdel_func.vcxproj.filters @@ -9,10 +9,6 @@ {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hh;hpp;hxx;hm;inl;inc;xsd - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - diff --git a/test/stress/map/insdel_func/map_insdel_func.cpp b/test/stress/map/insdel_func/map_insdel_func.cpp index 791adbcc..052e56ee 100644 --- a/test/stress/map/insdel_func/map_insdel_func.cpp +++ b/test/stress/map/insdel_func/map_insdel_func.cpp @@ -66,8 +66,8 @@ namespace map { s_nDeleteThreadCount = 2; s_nUpdateThreadCount = cfg.get_size_t( "UpdateThreadCount", s_nUpdateThreadCount ); - if ( s_nUpdateThreadCount == 0 ) - s_nUpdateThreadCount = 2; + //if ( s_nUpdateThreadCount == 0 ) + // s_nUpdateThreadCount = 2; s_nThreadPassCount = cfg.get_size_t( "ThreadPassCount", s_nThreadPassCount ); if ( s_nThreadPassCount == 0 ) diff --git a/test/stress/map/insdel_func/map_insdel_func.h b/test/stress/map/insdel_func/map_insdel_func.h index 856bdcd7..8b177a1f 100644 --- a/test/stress/map/insdel_func/map_insdel_func.h +++ b/test/stress/map/insdel_func/map_insdel_func.h @@ -432,7 +432,8 @@ namespace map { cds_test::thread_pool& pool = get_pool(); pool.add( new inserter( pool, testMap ), s_nInsertThreadCount ); pool.add( new deleter( pool, testMap ), s_nDeleteThreadCount ); - pool.add( new updater( pool, testMap ), s_nUpdateThreadCount ); + if ( s_nUpdateThreadCount ) + pool.add( new updater( pool, testMap ), s_nUpdateThreadCount ); propout() << std::make_pair( "insert_thread_count", s_nInsertThreadCount ) << std::make_pair( "delete_thread_count", s_nDeleteThreadCount ) @@ -530,6 +531,19 @@ namespace map { Map testMap( *this ); do_test( testMap ); } + + template + void run_test2() + { + Map testMap( *this ); + do_test( testMap ); + + if ( testMap.size() != 0 ) { + for ( auto it = testMap.begin(); it != testMap.end(); ++it ) { + std::cout << "key=" << it->first << std::endl; + } + } + } }; class Map_InsDel_func_LF: public Map_InsDel_func @@ -544,6 +558,14 @@ namespace map { Map_InsDel_func::run_test(); } + template + void run_test2() + { + s_nLoadFactor = GetParam(); + propout() << std::make_pair( "load_factor", s_nLoadFactor ); + Map_InsDel_func::run_test2(); + } + static std::vector get_load_factors(); }; diff --git a/test/stress/map/insdel_func/map_insdel_func_michael.cpp b/test/stress/map/insdel_func/map_insdel_func_michael.cpp index 9ad39bad..9b4d44cf 100644 --- a/test/stress/map/insdel_func/map_insdel_func_michael.cpp +++ b/test/stress/map/insdel_func/map_insdel_func_michael.cpp @@ -33,6 +33,6 @@ namespace map { - CDSSTRESS_MichaelMap( Map_InsDel_func_LF, run_test, size_t, Map_InsDel_func::value_type ) + CDSSTRESS_MichaelMap( Map_InsDel_func_LF, run_test2, size_t, Map_InsDel_func::value_type ) } // namespace map diff --git a/test/stress/set/insdel_func/set_insdel_func.h b/test/stress/set/insdel_func/set_insdel_func.h index dce5d148..2d7232c0 100644 --- a/test/stress/set/insdel_func/set_insdel_func.h +++ b/test/stress/set/insdel_func/set_insdel_func.h @@ -61,8 +61,8 @@ namespace set { size_t nKey; size_t nData; atomics::atomic nUpdateCall; - bool volatile bInitialized; - cds::OS::ThreadId threadId ; // insert thread id + bool volatile bInitialized; + cds::OS::ThreadId threadId; // insert thread id typedef cds::sync::spin_lock< cds::backoff::pause > lock_type; mutable lock_type m_access; @@ -100,7 +100,7 @@ namespace set { size_t * m_pKeyFirst; size_t * m_pKeyLast; - size_t * m_pKeyArr; + std::unique_ptr< size_t[] > m_pKeyArr; enum { insert_thread, @@ -418,8 +418,8 @@ namespace set { typedef Deleter DeleterThread; typedef Updater UpdaterThread; - m_pKeyArr = new size_t[ s_nSetSize ]; - m_pKeyFirst = m_pKeyArr; + m_pKeyArr.reset( new size_t[ s_nSetSize ] ); + m_pKeyFirst = m_pKeyArr.get(); m_pKeyLast = m_pKeyFirst + s_nSetSize; for ( size_t i = 0; i < s_nSetSize; ++i ) m_pKeyArr[i] = i; @@ -440,8 +440,6 @@ namespace set { propout() << std::make_pair( "duration", duration ); - delete [] m_pKeyArr; - size_t nInsertSuccess = 0; size_t nInsertFailed = 0; size_t nDeleteSuccess = 0; @@ -509,8 +507,12 @@ namespace set { // nTestFunctorRef is call count of insert functor EXPECT_EQ( nTestFunctorRef, nInsertSuccess ); - testSet.clear(); + //testSet.clear(); + for ( size_t * p = m_pKeyFirst; p != m_pKeyLast; ++p ) + testSet.erase( *p ); + EXPECT_TRUE( testSet.empty() ); + EXPECT_EQ( testSet.size(), 0u ); additional_check( testSet ); print_stat( propout(), testSet ); @@ -524,6 +526,16 @@ namespace set { Set s( *this ); run_test( s ); } + + template + void run_test2() + { + Set s( *this ); + run_test( s ); + + for ( auto it = s.begin(); it != s.end(); ++it ) + std::cout << "key=" << it->key << std::endl; + } }; class Set_InsDel_func_LF: public Set_InsDel_func @@ -538,6 +550,14 @@ namespace set { Set_InsDel_func::run_test(); } + template + void run_test2() + { + s_nLoadFactor = GetParam(); + propout() << std::make_pair( "load_factor", s_nLoadFactor ); + Set_InsDel_func::run_test2(); + } + static std::vector get_load_factors(); }; diff --git a/test/stress/set/insdel_func/set_insdel_func_michael.cpp b/test/stress/set/insdel_func/set_insdel_func_michael.cpp index 7c97e866..5c854a56 100644 --- a/test/stress/set/insdel_func/set_insdel_func_michael.cpp +++ b/test/stress/set/insdel_func/set_insdel_func_michael.cpp @@ -33,7 +33,7 @@ namespace set { - CDSSTRESS_MichaelSet( Set_InsDel_func_LF, run_test, size_t, value ) - CDSSTRESS_MichaelIterableSet( Set_InsDel_func_LF, run_test, size_t, value ) + CDSSTRESS_MichaelSet( Set_InsDel_func_LF, run_test2, size_t, value ) + CDSSTRESS_MichaelIterableSet( Set_InsDel_func_LF, run_test2, size_t, value ) } // namespace set