Improved test conditions
authorkhizmax <libcds.dev@gmail.com>
Thu, 6 Oct 2016 16:56:04 +0000 (19:56 +0300)
committerkhizmax <libcds.dev@gmail.com>
Thu, 6 Oct 2016 16:56:04 +0000 (19:56 +0300)
projects/Win/vc14/stress-set-insdel_func.vcxproj.filters
test/stress/map/insdel_func/map_insdel_func.cpp
test/stress/map/insdel_func/map_insdel_func.h
test/stress/map/insdel_func/map_insdel_func_michael.cpp
test/stress/set/insdel_func/set_insdel_func.h
test/stress/set/insdel_func/set_insdel_func_michael.cpp

index 39278ed0d9e51acb2222d49fe270b8f8ae5afffa..982c2cbb964c07ac828682d2fed9dc4ea96d4311 100644 (file)
@@ -9,10 +9,6 @@
       <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
       <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
     </Filter>
       <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
       <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
     </Filter>
-    <Filter Include="Resource Files">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\..\test\stress\main.cpp">
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\..\test\stress\main.cpp">
index 791adbcca89651ce840d5b4fcf9eef95eb6abb01..052e56ee7b90dc3b4573d267e21fb0cd92d3c4e5 100644 (file)
@@ -66,8 +66,8 @@ namespace map {
             s_nDeleteThreadCount = 2;
 
         s_nUpdateThreadCount = cfg.get_size_t( "UpdateThreadCount", s_nUpdateThreadCount );
             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 )
 
         s_nThreadPassCount = cfg.get_size_t( "ThreadPassCount", s_nThreadPassCount );
         if ( s_nThreadPassCount == 0 )
index 856bdcd78e2b219150492fc78d230dfdd3ae72e0..8b177a1f3fc912324070a505dc69fcf137f332ae 100644 (file)
@@ -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 );
             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 )
 
             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 );
         }
             Map testMap( *this );
             do_test( testMap );
         }
+
+        template <class Map>
+        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
     };
 
     class Map_InsDel_func_LF: public Map_InsDel_func
@@ -544,6 +558,14 @@ namespace map {
             Map_InsDel_func::run_test<Set>();
         }
 
             Map_InsDel_func::run_test<Set>();
         }
 
+        template <class Set>
+        void run_test2()
+        {
+            s_nLoadFactor = GetParam();
+            propout() << std::make_pair( "load_factor", s_nLoadFactor );
+            Map_InsDel_func::run_test2<Set>();
+        }
+
         static std::vector<size_t> get_load_factors();
     };
 
         static std::vector<size_t> get_load_factors();
     };
 
index 9ad39bad72b7f140576d50488cba50bd24a80591..9b4d44cf3a4a77fec61f2a51bf3bf66e0991f864 100644 (file)
@@ -33,6 +33,6 @@
 
 namespace map {
 
 
 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
 
 } // namespace map
index dce5d148c8937db08e90bfa4e378edb1d036c3b0..2d7232c0e8648b3400d7d9d76df5dbe0075e85e4 100644 (file)
@@ -61,8 +61,8 @@ namespace set {
             size_t      nKey;
             size_t      nData;
             atomics::atomic<size_t> nUpdateCall;
             size_t      nKey;
             size_t      nData;
             atomics::atomic<size_t> 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;
 
             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_pKeyFirst;
         size_t *    m_pKeyLast;
-        size_t *    m_pKeyArr;
+        std::unique_ptr< size_t[] > m_pKeyArr;
 
         enum {
             insert_thread,
 
         enum {
             insert_thread,
@@ -418,8 +418,8 @@ namespace set {
             typedef Deleter<Set>        DeleterThread;
             typedef Updater<Set>        UpdaterThread;
 
             typedef Deleter<Set>        DeleterThread;
             typedef Updater<Set>        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;
             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 );
 
 
             propout() << std::make_pair( "duration", duration );
 
-            delete [] m_pKeyArr;
-
             size_t nInsertSuccess = 0;
             size_t nInsertFailed = 0;
             size_t nDeleteSuccess = 0;
             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 );
 
             // 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_TRUE( testSet.empty() );
+            EXPECT_EQ( testSet.size(), 0u );
 
             additional_check( testSet );
             print_stat( propout(), testSet  );
 
             additional_check( testSet );
             print_stat( propout(), testSet  );
@@ -524,6 +526,16 @@ namespace set {
             Set s( *this );
             run_test( s );
         }
             Set s( *this );
             run_test( s );
         }
+
+        template <class Set>
+        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
     };
 
     class Set_InsDel_func_LF: public Set_InsDel_func
@@ -538,6 +550,14 @@ namespace set {
             Set_InsDel_func::run_test<Set>();
         }
 
             Set_InsDel_func::run_test<Set>();
         }
 
+        template <class Set>
+        void run_test2()
+        {
+            s_nLoadFactor = GetParam();
+            propout() << std::make_pair( "load_factor", s_nLoadFactor );
+            Set_InsDel_func::run_test2<Set>();
+        }
+
         static std::vector<size_t> get_load_factors();
     };
 
         static std::vector<size_t> get_load_factors();
     };
 
index 7c97e8664733f92dd7037cc1bed9e2ba6bd2838d..5c854a5623e10e3dbba101881370eaae46566698 100644 (file)
@@ -33,7 +33,7 @@
 
 namespace set {
 
 
 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
 
 } // namespace set