Splitted up set_insdelfind test
authorkhizmax <khizmax@gmail.com>
Fri, 27 Mar 2015 12:40:02 +0000 (15:40 +0300)
committerkhizmax <khizmax@gmail.com>
Fri, 27 Mar 2015 12:40:02 +0000 (15:40 +0300)
14 files changed:
projects/Win/vc12/unit-set-insdel.vcxproj
projects/Win/vc12/unit-set-insdel.vcxproj.filters
projects/source.unit.set.mk
tests/unit/set2/set_insdel_string.h
tests/unit/set2/set_insdelfind.cpp
tests/unit/set2/set_insdelfind.h [new file with mode: 0644]
tests/unit/set2/set_insdelfind_cuckoo.cpp [new file with mode: 0644]
tests/unit/set2/set_insdelfind_ellentree.cpp [new file with mode: 0644]
tests/unit/set2/set_insdelfind_michael.cpp [new file with mode: 0644]
tests/unit/set2/set_insdelfind_refinable.cpp [new file with mode: 0644]
tests/unit/set2/set_insdelfind_skip.cpp [new file with mode: 0644]
tests/unit/set2/set_insdelfind_split.cpp [new file with mode: 0644]
tests/unit/set2/set_insdelfind_std.cpp [new file with mode: 0644]
tests/unit/set2/set_insdelfind_striped.cpp [new file with mode: 0644]

index cb028abd9e62df5fd081d31eda09863bbd1f90bf..4efad4dd41f413e086d429e1ff3c36353790bf5f 100644 (file)
   </ItemGroup>\r
   <ItemGroup>\r
     <ClCompile Include="..\..\..\tests\unit\set2\set_insdelfind.cpp" />\r
+    <ClCompile Include="..\..\..\tests\unit\set2\set_insdelfind_cuckoo.cpp" />\r
+    <ClCompile Include="..\..\..\tests\unit\set2\set_insdelfind_ellentree.cpp" />\r
+    <ClCompile Include="..\..\..\tests\unit\set2\set_insdelfind_michael.cpp" />\r
+    <ClCompile Include="..\..\..\tests\unit\set2\set_insdelfind_refinable.cpp" />\r
+    <ClCompile Include="..\..\..\tests\unit\set2\set_insdelfind_skip.cpp" />\r
+    <ClCompile Include="..\..\..\tests\unit\set2\set_insdelfind_split.cpp" />\r
+    <ClCompile Include="..\..\..\tests\unit\set2\set_insdelfind_std.cpp" />\r
+    <ClCompile Include="..\..\..\tests\unit\set2\set_insdelfind_striped.cpp" />\r
     <ClCompile Include="..\..\..\tests\unit\set2\set_insdel_func.cpp" />\r
     <ClCompile Include="..\..\..\tests\unit\set2\set_insdel_func_cuckoo.cpp" />\r
     <ClCompile Include="..\..\..\tests\unit\set2\set_insdel_func_ellentree.cpp" />\r
@@ -62,6 +70,7 @@
     <ClCompile Include="..\..\..\tests\unit\set2\set_insdel_string_striped.cpp" />\r
   </ItemGroup>\r
   <ItemGroup>\r
+    <ClInclude Include="..\..\..\tests\unit\set2\set_insdelfind.h" />\r
     <ClInclude Include="..\..\..\tests\unit\set2\set_insdel_func.h" />\r
     <ClInclude Include="..\..\..\tests\unit\set2\set_insdel_string.h" />\r
   </ItemGroup>\r
index 604ad7f5b7c990ca4f0a4aa6f861ab31a7641234..ff6fd7451480420865da5e9bd90ed86e14729165 100644 (file)
     <ClCompile Include="..\..\..\tests\unit\set2\set_insdel_string_striped.cpp">\r
       <Filter>set_insdel_string</Filter>\r
     </ClCompile>\r
+    <ClCompile Include="..\..\..\tests\unit\set2\set_insdelfind_cuckoo.cpp">\r
+      <Filter>set_insdelfind</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\tests\unit\set2\set_insdelfind_ellentree.cpp">\r
+      <Filter>set_insdelfind</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\tests\unit\set2\set_insdelfind_michael.cpp">\r
+      <Filter>set_insdelfind</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\tests\unit\set2\set_insdelfind_refinable.cpp">\r
+      <Filter>set_insdelfind</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\tests\unit\set2\set_insdelfind_skip.cpp">\r
+      <Filter>set_insdelfind</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\tests\unit\set2\set_insdelfind_split.cpp">\r
+      <Filter>set_insdelfind</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\tests\unit\set2\set_insdelfind_std.cpp">\r
+      <Filter>set_insdelfind</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="..\..\..\tests\unit\set2\set_insdelfind_striped.cpp">\r
+      <Filter>set_insdelfind</Filter>\r
+    </ClCompile>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <Filter Include="set_insdel_func">\r
@@ -71,5 +95,8 @@
     <ClInclude Include="..\..\..\tests\unit\set2\set_insdel_string.h">\r
       <Filter>set_insdel_string</Filter>\r
     </ClInclude>\r
+    <ClInclude Include="..\..\..\tests\unit\set2\set_insdelfind.h">\r
+      <Filter>set_insdelfind</Filter>\r
+    </ClInclude>\r
   </ItemGroup>\r
 </Project>
\ No newline at end of file
index 66cf3196247792b922629d748a30f9bc495e585f..2f286246ae224a346699965a76e236482d849896 100644 (file)
@@ -17,6 +17,14 @@ CDSUNIT_SET_SOURCES := \
        tests/unit/set2/set_insdel_string_striped.cpp \
     tests/unit/set2/set_insdel_string_std.cpp \
        tests/unit/set2/set_insdelfind.cpp \
+    tests/unit/set2/set_insdelfind_michael.cpp \
+       tests/unit/set2/set_insdelfind_cuckoo.cpp \
+       tests/unit/set2/set_insdelfind_ellentree.cpp \
+       tests/unit/set2/set_insdelfind_refinable.cpp \
+       tests/unit/set2/set_insdelfind_skip.cpp \
+       tests/unit/set2/set_insdelfind_split.cpp \
+       tests/unit/set2/set_insdelfind_striped.cpp \
+    tests/unit/set2/set_insdelfind_std.cpp \
        tests/unit/set2/set_delodd.cpp \
        tests/unit/set2/set_delodd_cuckoo.cpp \
        tests/unit/set2/set_delodd_michael.cpp \
index 683009917481bf8bbd51a86d40474e3f8fc0f76b..359368fa40e93b3bffc16cf9ca60251f6b72497c 100644 (file)
@@ -538,7 +538,6 @@ namespace set2 {
 
         virtual void myRun(const char *in_name, bool invert = false);
 
-
 #   include "set2/set_defs.h"
         CDSUNIT_DECLARE_MichaelSet
         CDSUNIT_DECLARE_SplitList
index 0d4d5f45c3785bf32550f21a0890df108b071d8c..82c61d74de53c5291ca283bbd9e7e867baa3a582 100644 (file)
 //$$CDS-header$$
 
-#include "set2/set_types.h"
-#include "cppunit/thread.h"
-#include <algorithm> // random_shuffle
+#include "set2/set_insdelfind.h"
 
 namespace set2 {
+    CPPUNIT_TEST_SUITE_REGISTRATION( Set_InsDelFind );
 
-#   define TEST_SET(X)          void X() { test<SetTypes<key_type, value_type>::X >()    ; }
-#   define TEST_SET_EXTRACT(X)  TEST_SET(X)
-#   define TEST_SET_NOLF(X)    void X() { test_nolf<SetTypes<key_type, value_type>::X >()    ; }
-#   define TEST_SET_NOLF_EXTRACT(X) TEST_SET_NOLF(X)
+    size_t Set_InsDelFind::c_nInitialMapSize = 500000;
+    size_t Set_InsDelFind::c_nThreadCount = 8;
+    size_t Set_InsDelFind::c_nMaxLoadFactor = 8;
+    unsigned int Set_InsDelFind::c_nInsertPercentage = 5;
+    unsigned int Set_InsDelFind::c_nDeletePercentage = 5;
+    unsigned int Set_InsDelFind::c_nDuration = 30;
+    bool Set_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 Set_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 Set_InsDelFind: public CppUnitMini::TestCase
+    void Set_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 Set>
-        class WorkThread: public CppUnitMini::TestThread
-        {
-            Set&     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, Set& rMap )
-                : CppUnitMini::TestThread( pool )
-                , m_Map( rMap )
-            {}
-            WorkThread( WorkThread& src )
-                : CppUnitMini::TestThread( src )
-                , m_Map( src.m_Map )
-            {}
-
-            Set_InsDelFind&  getTest()
-            {
-                return reinterpret_cast<Set_InsDelFind&>( m_Pool.m_Test );
-            }
-
-            virtual void init() { cds::threading::Manager::attachThread()   ; }
-            virtual void fini() { cds::threading::Manager::detachThread()   ; }
-
-            virtual void test()
-            {
-                Set& 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 ))
-                            ++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 <class Set>
-        void do_test( size_t nLoadFactor )
-        {
-            CPPUNIT_MSG( "Load factor=" << nLoadFactor );
-
-            Set  testSet( c_nInitialMapSize, nLoadFactor );
-            do_test_with( testSet );
-        }
-
-        template <class Set>
-        void do_test_with( Set& testSet )
-        {
-            typedef WorkThread<Set> work_thread;
-
-            // fill map - only odd number
-            {
-                size_t * pInitArr = new size_t[ c_nInitialMapSize ];
-                size_t * pEnd = pInitArr + c_nInitialMapSize;
-                for ( size_t i = 0; i < c_nInitialMapSize; ++i )
-                    pInitArr[i] = i * 2 + 1;
-                std::random_shuffle( pInitArr, pEnd );
-                for ( size_t * p = pInitArr; p < pEnd; ++p )
-                    testSet.insert( typename Set::value_type( *p, *p ) );
-                delete [] pInitArr;
-            }
-
-            cds::OS::Timer    timer;
-
-            CppUnitMini::ThreadPool pool( *this );
-            pool.add( new work_thread( pool, testSet ), 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<work_thread *>( *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"
-                      << "      Set size=" << testSet.size()
-                );
-
-
-            CPPUNIT_MSG( "  Clear map (single-threaded)..." );
-            timer.reset();
-            testSet.clear();
-            CPPUNIT_MSG( "   Duration=" << timer.duration() );
-            CPPUNIT_CHECK_EX( testSet.empty(), ((long long) testSet.size()) );
-
-            additional_check( testSet );
-            print_stat( testSet );
-            additional_cleanup( testSet );
-        }
-
-        template <class Set>
-        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 ) {
-                do_test<Set>( nLoadFactor );
-                if ( c_bPrintGCState )
-                    print_gc_state();
-            }
-        }
-
-        template <class Set>
-        void test_nolf()
-        {
-            CPPUNIT_MSG( "Thread count=" << c_nThreadCount
-                << " initial map size=" << c_nInitialMapSize
-                << " insert=" << c_nInsertPercentage << '%'
-                << " delete=" << c_nDeletePercentage << '%'
-                << " duration=" << c_nDuration << "s"
-                );
-
-            Set s;
-            do_test_with( s );
-            //CPPUNIT_MSG( s.statistics() );
-            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 "set2/set_defs.h"
-        CDSUNIT_DECLARE_MichaelSet
-        CDSUNIT_DECLARE_SplitList
-        CDSUNIT_DECLARE_StripedSet
-        CDSUNIT_DECLARE_RefinableSet
-        CDSUNIT_DECLARE_CuckooSet
-        CDSUNIT_DECLARE_SkipListSet
-        CDSUNIT_DECLARE_EllenBinTreeSet
-        CDSUNIT_DECLARE_StdSet
+        setUpParams( m_Cfg.get( "Map_InsDelFind" ));
+
+        run_MichaelSet(in_name, invert);
+        run_SplitList(in_name, invert);
+        run_SkipListSet(in_name, invert);
+        run_EllenBinTreeSet(in_name, invert);
+        run_StripedSet(in_name, invert);
+        run_RefinableSet(in_name, invert);
+        run_CuckooSet(in_name, invert);
+        run_StdSet(in_name, invert);
+
+        endTestCase();
+    }
 
+    /*
         CPPUNIT_TEST_SUITE_( Set_InsDelFind, "Map_InsDelFind" )
             CDSUNIT_TEST_MichaelSet
             CDSUNIT_TEST_SplitList
@@ -274,7 +67,5 @@ namespace set2 {
             CDSUNIT_TEST_CuckooSet
             CDSUNIT_TEST_StdSet
         CPPUNIT_TEST_SUITE_END()
-    };
-
-    CPPUNIT_TEST_SUITE_REGISTRATION( Set_InsDelFind );
+        */
 } // namespace set2
diff --git a/tests/unit/set2/set_insdelfind.h b/tests/unit/set2/set_insdelfind.h
new file mode 100644 (file)
index 0000000..2a128cb
--- /dev/null
@@ -0,0 +1,253 @@
+//$$CDS-header$$
+
+#include "set2/set_types.h"
+#include "cppunit/thread.h"
+#include <algorithm> // random_shuffle
+
+namespace set2 {
+
+#   define TEST_SET(X)          void X() { test<SetTypes<key_type, value_type>::X >()    ; }
+#   define TEST_SET_EXTRACT(X)  TEST_SET(X)
+#   define TEST_SET_NOLF(X)    void X() { test_nolf<SetTypes<key_type, value_type>::X >()    ; }
+#   define TEST_SET_NOLF_EXTRACT(X) TEST_SET_NOLF(X)
+
+    class Set_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 Set>
+        class WorkThread: public CppUnitMini::TestThread
+        {
+            Set&     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, Set& rMap )
+                : CppUnitMini::TestThread( pool )
+                , m_Map( rMap )
+            {}
+            WorkThread( WorkThread& src )
+                : CppUnitMini::TestThread( src )
+                , m_Map( src.m_Map )
+            {}
+
+            Set_InsDelFind&  getTest()
+            {
+                return reinterpret_cast<Set_InsDelFind&>( m_Pool.m_Test );
+            }
+
+            virtual void init() { cds::threading::Manager::attachThread()   ; }
+            virtual void fini() { cds::threading::Manager::detachThread()   ; }
+
+            virtual void test()
+            {
+                Set& 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 ))
+                            ++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 <class Set>
+        void do_test( size_t nLoadFactor )
+        {
+            CPPUNIT_MSG( "Load factor=" << nLoadFactor );
+
+            Set  testSet( c_nInitialMapSize, nLoadFactor );
+            do_test_with( testSet );
+        }
+
+        template <class Set>
+        void do_test_with( Set& testSet )
+        {
+            typedef WorkThread<Set> work_thread;
+
+            // fill map - only odd number
+            {
+                size_t * pInitArr = new size_t[ c_nInitialMapSize ];
+                size_t * pEnd = pInitArr + c_nInitialMapSize;
+                for ( size_t i = 0; i < c_nInitialMapSize; ++i )
+                    pInitArr[i] = i * 2 + 1;
+                std::random_shuffle( pInitArr, pEnd );
+                for ( size_t * p = pInitArr; p < pEnd; ++p )
+                    testSet.insert( typename Set::value_type( *p, *p ) );
+                delete [] pInitArr;
+            }
+
+            cds::OS::Timer    timer;
+
+            CppUnitMini::ThreadPool pool( *this );
+            pool.add( new work_thread( pool, testSet ), 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<work_thread *>( *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"
+                      << "      Set size=" << testSet.size()
+                );
+
+
+            CPPUNIT_MSG( "  Clear map (single-threaded)..." );
+            timer.reset();
+            testSet.clear();
+            CPPUNIT_MSG( "   Duration=" << timer.duration() );
+            CPPUNIT_CHECK_EX( testSet.empty(), ((long long) testSet.size()) );
+
+            additional_check( testSet );
+            print_stat( testSet );
+            additional_cleanup( testSet );
+        }
+
+        template <class Set>
+        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 ) {
+                do_test<Set>( nLoadFactor );
+                if ( c_bPrintGCState )
+                    print_gc_state();
+            }
+        }
+
+        template <class Set>
+        void test_nolf()
+        {
+            CPPUNIT_MSG( "Thread count=" << c_nThreadCount
+                << " initial map size=" << c_nInitialMapSize
+                << " insert=" << c_nInsertPercentage << '%'
+                << " delete=" << c_nDeletePercentage << '%'
+                << " duration=" << c_nDuration << "s"
+                );
+
+            Set s;
+            do_test_with( s );
+            //CPPUNIT_MSG( s.statistics() );
+            if ( c_bPrintGCState )
+                print_gc_state();
+        }
+
+        void setUpParams( const CppUnitMini::TestCfg& cfg );
+
+        void run_MichaelSet(const char *in_name, bool invert = false);
+        void run_SplitList(const char *in_name, bool invert = false);
+        void run_SkipListSet(const char *in_name, bool invert = false);
+        void run_CuckooSet(const char *in_name, bool invert = false);
+        void run_StripedSet(const char *in_name, bool invert = false);
+        void run_RefinableSet(const char *in_name, bool invert = false);
+        void run_EllenBinTreeSet(const char *in_name, bool invert = false);
+        void run_StdSet(const char *in_name, bool invert = false);
+
+        virtual void myRun(const char *in_name, bool invert = false);
+
+#   include "set2/set_defs.h"
+        CDSUNIT_DECLARE_MichaelSet
+        CDSUNIT_DECLARE_SplitList
+        CDSUNIT_DECLARE_StripedSet
+        CDSUNIT_DECLARE_RefinableSet
+        CDSUNIT_DECLARE_CuckooSet
+        CDSUNIT_DECLARE_SkipListSet
+        CDSUNIT_DECLARE_EllenBinTreeSet
+        CDSUNIT_DECLARE_StdSet
+    };
+} // namespace set2
diff --git a/tests/unit/set2/set_insdelfind_cuckoo.cpp b/tests/unit/set2/set_insdelfind_cuckoo.cpp
new file mode 100644 (file)
index 0000000..f5986ab
--- /dev/null
@@ -0,0 +1,9 @@
+//$$CDS-header$$
+
+#include "set2/set_insdelfind.h"
+
+namespace set2 {
+    CPPUNIT_TEST_SUITE_PART( Set_InsDelFind, run_CuckooSet )
+        CDSUNIT_TEST_CuckooSet
+    CPPUNIT_TEST_SUITE_END_PART()
+} // namespace set2
diff --git a/tests/unit/set2/set_insdelfind_ellentree.cpp b/tests/unit/set2/set_insdelfind_ellentree.cpp
new file mode 100644 (file)
index 0000000..db2a7e3
--- /dev/null
@@ -0,0 +1,9 @@
+//$$CDS-header$$
+
+#include "set2/set_insdelfind.h"
+
+namespace set2 {
+    CPPUNIT_TEST_SUITE_PART( Set_InsDelFind, run_EllenBinTreeSet )
+        CDSUNIT_TEST_EllenBinTreeSet
+    CPPUNIT_TEST_SUITE_END_PART()
+} // namespace set2
diff --git a/tests/unit/set2/set_insdelfind_michael.cpp b/tests/unit/set2/set_insdelfind_michael.cpp
new file mode 100644 (file)
index 0000000..631111f
--- /dev/null
@@ -0,0 +1,9 @@
+//$$CDS-header$$
+
+#include "set2/set_insdelfind.h"
+
+namespace set2 {
+    CPPUNIT_TEST_SUITE_PART( Set_InsDelFind, run_MichaelSet )
+        CDSUNIT_TEST_MichaelSet
+    CPPUNIT_TEST_SUITE_END_PART()
+} // namespace set2
diff --git a/tests/unit/set2/set_insdelfind_refinable.cpp b/tests/unit/set2/set_insdelfind_refinable.cpp
new file mode 100644 (file)
index 0000000..942113e
--- /dev/null
@@ -0,0 +1,9 @@
+//$$CDS-header$$
+
+#include "set2/set_insdelfind.h"
+
+namespace set2 {
+    CPPUNIT_TEST_SUITE_PART( Set_InsDelFind, run_RefinableSet )
+        CDSUNIT_TEST_RefinableSet
+    CPPUNIT_TEST_SUITE_END_PART()
+} // namespace set2
diff --git a/tests/unit/set2/set_insdelfind_skip.cpp b/tests/unit/set2/set_insdelfind_skip.cpp
new file mode 100644 (file)
index 0000000..8e49865
--- /dev/null
@@ -0,0 +1,9 @@
+//$$CDS-header$$
+
+#include "set2/set_insdelfind.h"
+
+namespace set2 {
+    CPPUNIT_TEST_SUITE_PART( Set_InsDelFind, run_SkipListSet )
+        CDSUNIT_TEST_SkipListSet
+    CPPUNIT_TEST_SUITE_END_PART()
+} // namespace set2
diff --git a/tests/unit/set2/set_insdelfind_split.cpp b/tests/unit/set2/set_insdelfind_split.cpp
new file mode 100644 (file)
index 0000000..c16b852
--- /dev/null
@@ -0,0 +1,9 @@
+//$$CDS-header$$
+
+#include "set2/set_insdelfind.h"
+
+namespace set2 {
+    CPPUNIT_TEST_SUITE_PART( Set_InsDelFind, run_SplitList )
+        CDSUNIT_TEST_SplitList
+    CPPUNIT_TEST_SUITE_END_PART()
+} // namespace set2
diff --git a/tests/unit/set2/set_insdelfind_std.cpp b/tests/unit/set2/set_insdelfind_std.cpp
new file mode 100644 (file)
index 0000000..7543b88
--- /dev/null
@@ -0,0 +1,9 @@
+//$$CDS-header$$
+
+#include "set2/set_insdelfind.h"
+
+namespace set2 {
+    CPPUNIT_TEST_SUITE_PART( Set_InsDelFind, run_StdSet )
+        CDSUNIT_TEST_StdSet
+    CPPUNIT_TEST_SUITE_END_PART()
+} // namespace set2
diff --git a/tests/unit/set2/set_insdelfind_striped.cpp b/tests/unit/set2/set_insdelfind_striped.cpp
new file mode 100644 (file)
index 0000000..f98d69f
--- /dev/null
@@ -0,0 +1,9 @@
+//$$CDS-header$$
+
+#include "set2/set_insdelfind.h"
+
+namespace set2 {
+    CPPUNIT_TEST_SUITE_PART( Set_InsDelFind, run_StripedSet )
+        CDSUNIT_TEST_StripedSet
+    CPPUNIT_TEST_SUITE_END_PART()
+} // namespace set2