ProfileTree.st
changeset 559 8015fde9ae16
parent 263 4c3889934577
child 560 50dc521a1a1d
--- a/ProfileTree.st	Mon Mar 17 18:19:23 1997 +0100
+++ b/ProfileTree.st	Wed Mar 19 12:40:49 1997 +0100
@@ -268,6 +268,24 @@
     "Modified: 18.5.1996 / 19:04:03 / cg"
 !
 
+printMethodLeafsOn:aStream
+    "print all method leafNodes statistics on aStream"
+
+    |leafNodes|
+
+    leafNodes := OrderedCollection new.
+    self addMethodLeafNodesTo:leafNodes.
+    leafNodes := leafNodes asSortedCollection:[:a :b |
+                                        a leafTally < b leafTally].
+    leafNodes do:[:aNode |
+        aNode printSingleMethodOn:aStream.
+        aStream cr.
+    ].
+
+    "Created: 19.3.1997 / 12:19:31 / cg"
+    "Modified: 19.3.1997 / 12:34:39 / cg"
+!
+
 printOn:aStream
     "print statistics on aStream"
 
@@ -300,6 +318,40 @@
     "Modified: 18.5.1996 / 19:04:12 / cg"
 !
 
+printSingleMethodOn:aStream
+    "print a single nodes statistic on aStream"
+
+    |cls|
+
+    selector notNil ifTrue:[
+        isBlock == true ifTrue:[
+            '[] in ' printOn:aStream
+        ].
+        (class notNil and:[class ~~ receiver class]) ifTrue:[
+            cls := class
+        ] ifFalse:[
+            cls := receiver.
+        ].
+        cls name printOn:aStream.
+        aStream space.
+        selector printOn:aStream.
+        aStream space.
+
+        leafTally notNil ifTrue:[
+            aStream nextPutAll:'(leaf '.
+            leafTally printOn:aStream.
+            aStream nextPutAll:'%)'.
+        ] ifFalse:[
+            aStream nextPutAll:'(total '.
+            totalTally printOn:aStream.
+            aStream nextPutAll:'%)'.
+        ]
+    ].
+
+    "Created: 19.3.1997 / 12:33:46 / cg"
+    "Modified: 19.3.1997 / 12:36:44 / cg"
+!
+
 printSingleOn:aStream
     "print a single nodes statistic on aStream"
 
@@ -335,12 +387,12 @@
 = aProfileTreeNode
     "return true, if the argument tree is for the same method invocation"
 
-    receiver ~= aProfileTreeNode receiver ifTrue:[^ false].
     selector ~~ aProfileTreeNode selector ifTrue:[^ false].
     class ~~ aProfileTreeNode methodClass ifTrue:[^ false].
+    receiver ~= aProfileTreeNode receiver ifTrue:[^ false].
     ^ true
 
-    "Modified: 18.5.1996 / 19:04:40 / cg"
+    "Modified: 19.3.1997 / 12:23:41 / cg"
 !
 
 addLeafNodesTo:aCollection
@@ -349,7 +401,7 @@
     |idx|
 
     leafTally notNil ifTrue:[
-        idx := aCollection  indexOf:self.
+        idx := aCollection indexOf:self.
         idx == 0 ifTrue:[
             aCollection add:self copy
         ] ifFalse:[
@@ -366,11 +418,47 @@
         ]
     ]
 
-    "Modified: 18.5.1996 / 19:04:56 / cg"
+    "Modified: 19.3.1997 / 12:23:49 / cg"
+!
+
+addMethodLeafNodesTo:aCollection
+    "add all method leaf nodes to aCollection"
+
+    |idx|
+
+    leafTally notNil ifTrue:[
+        idx := aCollection findFirst:[:el | el sameMethodAsIn:self].
+        idx == 0 ifTrue:[
+            aCollection add:self copy
+        ] ifFalse:[
+            |nd|
+
+            nd := aCollection at:idx.
+            nd leafTally:(nd leafTally + leafTally).
+            nd totalTally:(nd totalTally max: totalTally)
+        ]
+    ].
+    called notNil ifTrue:[
+        called do:[:aNode |
+            aNode addMethodLeafNodesTo:aCollection
+        ]
+    ]
+
+    "Modified: 19.3.1997 / 12:26:05 / cg"
+!
+
+sameMethodAsIn:aProfileTreeNode
+    "return true, if the argument tree is for the same method invocation"
+
+    selector ~~ aProfileTreeNode selector ifTrue:[^ false].
+    class ~~ aProfileTreeNode methodClass ifTrue:[^ false].
+    ^ true
+
+    "Created: 19.3.1997 / 12:23:24 / cg"
 ! !
 
 !ProfileTree class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic3/ProfileTree.st,v 1.13 1996-05-18 17:14:47 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic3/ProfileTree.st,v 1.14 1997-03-19 11:40:49 cg Exp $'
 ! !