From: khizmax Date: Wed, 18 Mar 2015 08:22:17 +0000 (+0300) Subject: Added more statistics to BronsonAVLTree X-Git-Tag: v2.1.0~299 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=1d51ebf8ed07a386e2660b3530337a64db3eeccb;p=libcds.git Added more statistics to BronsonAVLTree --- diff --git a/cds/container/details/bronson_avltree_base.h b/cds/container/details/bronson_avltree_base.h index 95290cde..2b4839b6 100644 --- a/cds/container/details/bronson_avltree_base.h +++ b/cds/container/details/bronson_avltree_base.h @@ -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 }; diff --git a/cds/container/impl/bronson_avltree_map_rcu.h b/cds/container/impl/bronson_avltree_map_rcu.h index daffdb7d..87a85f6a 100644 --- a/cds/container/impl/bronson_avltree_map_rcu.h +++ b/cds/container/impl/bronson_avltree_map_rcu.h @@ -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 { diff --git a/tests/unit/print_bronsonavltree_stat.h b/tests/unit/print_bronsonavltree_stat.h index e34c491d..f237a283 100644 --- a/tests/unit/print_bronsonavltree_stat.h +++ b/tests/unit/print_bronsonavltree_stat.h @@ -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