Added more statistics to BronsonAVLTree
authorkhizmax <libcds.dev@gmail.com>
Wed, 18 Mar 2015 08:22:17 +0000 (11:22 +0300)
committerkhizmax <libcds.dev@gmail.com>
Wed, 18 Mar 2015 08:22:17 +0000 (11:22 +0300)
cds/container/details/bronson_avltree_base.h
cds/container/impl/bronson_avltree_map_rcu.h
tests/unit/print_bronsonavltree_stat.h

index 95290cde62061ebac2d5419cd1ccdf0c23584b9a..2b4839b69ad6f39d2e8fb1ffcbe386e1479f202e 100644 (file)
@@ -190,6 +190,9 @@ namespace cds { namespace container {
             event_counter   m_nLeftRightRotation;   ///< Count of double left-over-right rotation
             event_counter   m_nRightLeftRotation;   ///< Count of double right-over-left rotation
 
+            event_counter   m_nInsertRebalanceReq;  ///< Count of rebalance required after inserting
+            event_counter   m_nRemoveRebalanceReq;  ///< Count of rebalance required after removing
+
             //@cond
             void onFindSuccess()        { ++m_nFindSuccess      ; }
             void onFindFailed()         { ++m_nFindFailed       ; }
@@ -215,6 +218,9 @@ namespace cds { namespace container {
             void onRotateLeft()             { ++m_nLeftRotation; }
             void onRotateRightOverLeft()    { ++m_nRightLeftRotation; }
             void onRotateLeftOverRight()    { ++m_nLeftRightRotation; }
+
+            void onInsertRebalanceRequired() { ++m_nInsertRebalanceReq; }
+            void onRemoveRebalanceRequired() { ++m_nRemoveRebalanceReq; }
             //@endcond
         };
 
@@ -245,6 +251,9 @@ namespace cds { namespace container {
             void onRotateLeft()             const {}
             void onRotateRightOverLeft()    const {}
             void onRotateLeftOverRight()    const {}
+
+            void onInsertRebalanceRequired() const {}
+            void onRemoveRebalanceRequired() const {}
             //@endcond
         };
 
index daffdb7d02fed6e5009c1178a2dc237b03db4c77..87a85f6af32fcd925ce2a6878c1897bded321e68 100644 (file)
@@ -1252,7 +1252,10 @@ namespace cds { namespace container {
             ++m_ItemCounter;
             m_stat.onInsertSuccess();
 
-            fix_height_and_rebalance( pDamaged, disp );
+            if ( pDamaged ) {
+                fix_height_and_rebalance( pDamaged, disp );
+                m_stat.onInsertRebalanceRequired();
+            }
 
             return update_flags::result_inserted;
         }
@@ -1327,7 +1330,10 @@ namespace cds { namespace container {
                 else
                     m_stat.onExtractValue();
 
-                fix_height_and_rebalance( pDamaged, disp );
+                if ( pDamaged ) {
+                    fix_height_and_rebalance( pDamaged, disp );
+                    m_stat.onRemoveRebalanceRequired();
+                }
                 return update_flags::result_removed;
             }
             else {
index e34c491d8b47e718a061af512fdc79c0f508b9e3..f237a28363f870d7541a928235d7ee0257212d4e 100644 (file)
@@ -36,7 +36,10 @@ namespace std {
             << "\t\t          m_nRightRotation: " << s.m_nRightRotation.get()       << "\n"
             << "\t\t           m_nLeftRotation: " << s.m_nLeftRotation.get()        << "\n"
             << "\t\t      m_nLeftRightRotation: " << s.m_nLeftRightRotation.get()   << "\n"
-            << "\t\t      m_nRightLeftRotation: " << s.m_nRightLeftRotation.get()   << "\n";
+            << "\t\t      m_nRightLeftRotation: " << s.m_nRightLeftRotation.get()   << "\n"
+            << "\t\t     m_nInsertRebalanceReq: " << s.m_nInsertRebalanceReq.get()  << "\n"
+            << "\t\t     m_nRemoveRebalanceReq: " << s.m_nRemoveRebalanceReq.get()  << "\n"
+            ;
     }
 } //namespace std