Refactors some of existing cds multi-threaded stress test cases
[libcds.git] / test / stress / map / insdelfind / map_insdelfind.h
index df52df45a262e5c08c6a4c0e84f96bca4b12e2c3..d11b835794bf0739129e221a043f5b9578401610 100644 (file)
@@ -1,7 +1,7 @@
 /*
     This file is a part of libcds - Concurrent Data Structures library
 
-    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
 
     Source code repo: http://github.com/khizmax/libcds/
     Download: http://sourceforge.net/projects/libcds/files/
@@ -38,6 +38,7 @@ namespace map {
     public:
         static size_t s_nMapSize;           // initial map size
         static size_t s_nThreadCount;       // thread count
+        static size_t s_nPassCount;         // pass count
         static size_t s_nMaxLoadFactor;     // maximum load factor
         static unsigned int s_nInsertPercentage;
         static unsigned int s_nDeletePercentage;
@@ -127,7 +128,7 @@ namespace map {
                 size_t const nNormalize = size_t(-1) / ( s_nMapSize * 2 );
 
                 size_t nRand = 0;
-                while ( !time_elapsed() ) {
+                for (size_t pCount; pCount < s_nPassCount; pCount++) {
                     nRand = cds::bitop::RandXorShift( nRand );
                     size_t n = nRand / nNormalize;
                     switch ( s_arrShuffle[i] ) {
@@ -177,7 +178,7 @@ namespace map {
                 arr.reserve( s_nMapSize );
                 for ( size_t i = 0; i < s_nMapSize; ++i )
                     arr.push_back( i * 2 + 1);
-                shuffle( arr.begin(), arr.end() );
+                shuffle( arr.begin(), arr.end());
                 for ( size_t i = 0; i < s_nMapSize; ++i )
                     testMap.insert( arr[i], arr[i] );
             }
@@ -190,7 +191,7 @@ namespace map {
                 << std::make_pair( "delete_percentage", s_nDeletePercentage )
                 << std::make_pair( "map_size", s_nMapSize );
 
-            std::chrono::milliseconds duration = pool.run( std::chrono::seconds( s_nDuration ));
+            std::chrono::milliseconds duration = pool.run();
 
             propout() << std::make_pair( "duration", duration );
 
@@ -218,7 +219,7 @@ namespace map {
                 << std::make_pair( "delete_failed", nDeleteFailed )
                 << std::make_pair( "find_success", nFindSuccess )
                 << std::make_pair( "find_failed", nFindFailed )
-                << std::make_pair( "finish_map_size", testMap.size() );
+                << std::make_pair( "finish_map_size", testMap.size());
 
             {
                 ASSERT_TRUE( std::chrono::duration_cast<std::chrono::seconds>(duration).count() > 0 );