From 08a9eb7cb9f0aa03e8dd3b25e45a6a2f3027eeee Mon Sep 17 00:00:00 2001 From: khizmax Date: Thu, 28 Jul 2016 13:51:15 +0300 Subject: [PATCH] Added internal measurements to MSPriorityQueue --- cds/intrusive/mspriority_queue.h | 47 ++++++++++++++++++++++---------- test/stress/pqueue/pqueue_type.h | 5 +++- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/cds/intrusive/mspriority_queue.h b/cds/intrusive/mspriority_queue.h index 0c9cbe7f..6d2ddb89 100644 --- a/cds/intrusive/mspriority_queue.h +++ b/cds/intrusive/mspriority_queue.h @@ -53,12 +53,15 @@ namespace cds { namespace intrusive { struct stat { typedef Counter event_counter ; ///< Event counter type - event_counter m_nPushCount ; ///< Count of success push operation - event_counter m_nPopCount ; ///< Count of success pop operation - event_counter m_nPushFailCount ; ///< Count of failed ("the queue is full") push operation - event_counter m_nPopFailCount ; ///< Count of failed ("the queue is empty") pop operation - event_counter m_nPushHeapifySwapCount ; ///< Count of item swapping when heapifying in push - event_counter m_nPopHeapifySwapCount ; ///< Count of item swapping when heapifying in pop + event_counter m_nPushCount; ///< Count of success push operation + event_counter m_nPopCount; ///< Count of success pop operation + event_counter m_nPushFailCount; ///< Count of failed ("the queue is full") push operation + event_counter m_nPopFailCount; ///< Count of failed ("the queue is empty") pop operation + event_counter m_nPushHeapifySwapCount; ///< Count of item swapping when heapifying in push + event_counter m_nPopHeapifySwapCount; ///< Count of item swapping when heapifying in pop + event_counter m_nItemMovedTop; ///< Count of events when \p push() encountered that inserted item was moved to top by a concurrent \p pop() + event_counter m_nItemMovedUp; ///< Count of events when \p push() encountered that inserted item was moved upwards by a concurrent \p pop() + event_counter m_nPushEmptyPass; ///< Count of empty pass during heapify via concurrent operations //@cond void onPushSuccess() { ++m_nPushCount ;} @@ -67,18 +70,26 @@ namespace cds { namespace intrusive { void onPopFailed() { ++m_nPopFailCount ;} void onPushHeapifySwap() { ++m_nPushHeapifySwapCount ;} void onPopHeapifySwap() { ++m_nPopHeapifySwapCount ;} + + void onItemMovedTop() { ++m_nItemMovedTop ;} + void onItemMovedUp() { ++m_nItemMovedUp ;} + void onPushEmptyPass() { ++m_nPushEmptyPass ;} //@endcond }; /// MSPriorityQueue empty statistics struct empty_stat { //@cond - void onPushSuccess() {} - void onPopSuccess() {} - void onPushFailed() {} - void onPopFailed() {} - void onPushHeapifySwap() {} - void onPopHeapifySwap() {} + void onPushSuccess() const {} + void onPopSuccess() const {} + void onPushFailed() const {} + void onPopFailed() const {} + void onPushHeapifySwap() const {} + void onPopHeapifySwap() const {} + + void onItemMovedTop() const {} + void onItemMovedUp() const {} + void onPushEmptyPass() const {} //@endcond }; @@ -438,12 +449,18 @@ namespace cds { namespace intrusive { i = 0; } } - else if ( refParent.m_nTag == tag_type(Empty) ) + else if ( refParent.m_nTag == tag_type( Empty ) ) { + m_Stat.onItemMovedTop(); i = 0; - else if ( refItem.m_nTag != curId ) + } + else if ( refItem.m_nTag != curId ) { + m_Stat.onItemMovedUp(); i = nParent; - else + } + else { + m_Stat.onPushEmptyPass(); bProgress = false; + } refItem.unlock(); refParent.unlock(); diff --git a/test/stress/pqueue/pqueue_type.h b/test/stress/pqueue/pqueue_type.h index 1df733d1..8e20517b 100644 --- a/test/stress/pqueue/pqueue_type.h +++ b/test/stress/pqueue/pqueue_type.h @@ -640,7 +640,10 @@ namespace cds_test { << CDSSTRESS_STAT_OUT( s, m_nPushFailCount ) << CDSSTRESS_STAT_OUT( s, m_nPopFailCount ) << CDSSTRESS_STAT_OUT( s, m_nPushHeapifySwapCount ) - << CDSSTRESS_STAT_OUT( s, m_nPopHeapifySwapCount ); + << CDSSTRESS_STAT_OUT( s, m_nPopHeapifySwapCount ) + << CDSSTRESS_STAT_OUT( s, m_nItemMovedTop ) + << CDSSTRESS_STAT_OUT( s, m_nItemMovedUp ) + << CDSSTRESS_STAT_OUT( s, m_nPushEmptyPass ); } } // namespace cds_test -- 2.34.1