Added internal measurements to MSPriorityQueue
authorkhizmax <khizmax@gmail.com>
Thu, 28 Jul 2016 10:51:15 +0000 (13:51 +0300)
committerkhizmax <khizmax@gmail.com>
Thu, 28 Jul 2016 10:51:15 +0000 (13:51 +0300)
cds/intrusive/mspriority_queue.h
test/stress/pqueue/pqueue_type.h

index 0c9cbe7fe1e0f6c28809df21c65787247800ba23..6d2ddb896fbd8205f74aa780d32ec45de5f6ba74 100644 (file)
@@ -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();
index 1df733d17b31f028f867d6146616b567f77f3471..8e20517b45f6c36f2d5f02bd1bb8fa6337e00456 100644 (file)
@@ -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