Improved map unit test
authorkhizmax <libcds.dev@gmail.com>
Sun, 5 Apr 2015 09:49:51 +0000 (12:49 +0300)
committerkhizmax <libcds.dev@gmail.com>
Sun, 5 Apr 2015 09:49:51 +0000 (12:49 +0300)
tests/data/test-debug.conf
tests/unit/map2/map_delodd.h

index c72ae739669b6352f44bd2dc7d83d875eb7648d2..c765db2b1824f358185e6cef7563b40c52efb974 100644 (file)
@@ -188,7 +188,7 @@ Duration=7
 PrintGCStateFlag=1\r
 \r
 [Map_DelOdd]\r
-MapSize=500000\r
+MapSize=50000\r
 InsThreadCount=2\r
 DelThreadCount=2\r
 ExtractThreadCount=2\r
index 226098bd9faed56bfdc6b8c35507a4449788c785..661571a76f792bbdb39acd9a147ced40f72f5ddf 100644 (file)
@@ -276,33 +276,35 @@ namespace map2 {
                 m_nDeleteSuccess =
                     m_nDeleteFailed = 0;
 
-                std::vector<size_t>& arrData = getTest().m_arrData;
-                if ( m_nThreadNo & 1 ) {
-                    for ( size_t k = 0; k < c_nInsThreadCount; ++k ) {
-                        for ( size_t i = 0; i < arrData.size(); ++i ) {
-                            if ( arrData[i] & 1 ) {
-                                if ( rMap.erase_with( arrData[i], key_less() ))
-                                    ++m_nDeleteSuccess;
-                                else
-                                    ++m_nDeleteFailed;
+                for ( size_t pass = 0; pass < 2; pass++ ) {
+                    std::vector<size_t>& arrData = getTest().m_arrData;
+                    if ( m_nThreadNo & 1 ) {
+                        for ( size_t k = 0; k < c_nInsThreadCount; ++k ) {
+                            for ( size_t i = 0; i < arrData.size(); ++i ) {
+                                if ( arrData[i] & 1 ) {
+                                    if ( rMap.erase_with( arrData[i], key_less() ))
+                                        ++m_nDeleteSuccess;
+                                    else
+                                        ++m_nDeleteFailed;
+                                }
                             }
+                            if ( getTest().m_nInsThreadCount.load( atomics::memory_order_acquire ) == 0 )
+                                break;
                         }
-                        if ( getTest().m_nInsThreadCount.load( atomics::memory_order_acquire ) == 0 )
-                            break;
                     }
-                }
-                else {
-                    for ( size_t k = 0; k < c_nInsThreadCount; ++k ) {
-                        for ( size_t i = arrData.size() - 1; i > 0; --i ) {
-                            if ( arrData[i] & 1 ) {
-                                if ( rMap.erase_with( arrData[i], key_less() ))
-                                    ++m_nDeleteSuccess;
-                                else
-                                    ++m_nDeleteFailed;
+                    else {
+                        for ( size_t k = 0; k < c_nInsThreadCount; ++k ) {
+                            for ( size_t i = arrData.size() - 1; i > 0; --i ) {
+                                if ( arrData[i] & 1 ) {
+                                    if ( rMap.erase_with( arrData[i], key_less() ))
+                                        ++m_nDeleteSuccess;
+                                    else
+                                        ++m_nDeleteFailed;
+                                }
                             }
+                            if ( getTest().m_nInsThreadCount.load( atomics::memory_order_acquire ) == 0 )
+                                break;
                         }
-                        if ( getTest().m_nInsThreadCount.load( atomics::memory_order_acquire ) == 0 )
-                            break;
                     }
                 }
             }
@@ -349,37 +351,39 @@ namespace map2 {
 
                 typename Map::guarded_ptr gp;
 
-                std::vector<size_t>& arrData = getTest().m_arrData;
-                if ( m_nThreadNo & 1 ) {
-                    for ( size_t k = 0; k < c_nInsThreadCount; ++k ) {
-                        for ( size_t i = 0; i < arrData.size(); ++i ) {
-                            if ( arrData[i] & 1 ) {
-                                gp = rMap.extract_with( arrData[i], key_less());
-                                if ( gp )
-                                    ++m_nDeleteSuccess;
-                                else
-                                    ++m_nDeleteFailed;
-                                gp.release();
+                for ( size_t pass = 0; pass < 2; ++pass ) {
+                    std::vector<size_t>& arrData = getTest().m_arrData;
+                    if ( m_nThreadNo & 1 ) {
+                        for ( size_t k = 0; k < c_nInsThreadCount; ++k ) {
+                            for ( size_t i = 0; i < arrData.size(); ++i ) {
+                                if ( arrData[i] & 1 ) {
+                                    gp = rMap.extract_with( arrData[i], key_less());
+                                    if ( gp )
+                                        ++m_nDeleteSuccess;
+                                    else
+                                        ++m_nDeleteFailed;
+                                    gp.release();
+                                }
                             }
+                            if ( getTest().m_nInsThreadCount.load( atomics::memory_order_acquire ) == 0 )
+                                break;
                         }
-                        if ( getTest().m_nInsThreadCount.load( atomics::memory_order_acquire ) == 0 )
-                            break;
                     }
-                }
-                else {
-                    for ( size_t k = 0; k < c_nInsThreadCount; ++k ) {
-                        for ( size_t i = arrData.size() - 1; i > 0; --i ) {
-                            if ( arrData[i] & 1 ) {
-                                gp = rMap.extract_with( arrData[i], key_less());
-                                if ( gp )
-                                    ++m_nDeleteSuccess;
-                                else
-                                    ++m_nDeleteFailed;
-                                gp.release();
+                    else {
+                        for ( size_t k = 0; k < c_nInsThreadCount; ++k ) {
+                            for ( size_t i = arrData.size() - 1; i > 0; --i ) {
+                                if ( arrData[i] & 1 ) {
+                                    gp = rMap.extract_with( arrData[i], key_less());
+                                    if ( gp )
+                                        ++m_nDeleteSuccess;
+                                    else
+                                        ++m_nDeleteFailed;
+                                    gp.release();
+                                }
                             }
+                            if ( getTest().m_nInsThreadCount.load( atomics::memory_order_acquire ) == 0 )
+                                break;
                         }
-                        if ( getTest().m_nInsThreadCount.load( atomics::memory_order_acquire ) == 0 )
-                            break;
                     }
                 }
             }