ProfileTree.st
changeset 23 a85cd774be98
parent 22 2911230f8e8e
child 24 10e1150b1f4b
--- a/ProfileTree.st	Thu Mar 09 00:41:17 1995 +0100
+++ b/ProfileTree.st	Thu Mar 09 11:46:36 1995 +0100
@@ -7,19 +7,28 @@
 	 category:'System-Profiler'
 !
 
+!ProfileTree class methodsFor:'documentation'!
+
+documentation
+"
+    This is is used as a companion to MessageTally.
+    Instances of it are used to represent the calling tree.
+"
+! !
+
 !ProfileTree methodsFor:'prettyPrinting'!
 
 printOn:aStream indent:i
     selector notNil ifTrue:[
-        aStream spaces:i.
-        self printSingleOn:aStream.
-        aStream cr.
+	aStream spaces:i.
+	self printSingleOn:aStream.
+	aStream cr.
     ].
 
     called notNil ifTrue:[
-        called do:[:sub|
-            sub printOn:aStream indent:(i + 1)
-        ].
+	called do:[:sub|
+	    sub printOn:aStream indent:(i + 1)
+	].
     ].
 !
 
@@ -35,27 +44,27 @@
 
 printSingleOn:aStream
     selector notNil ifTrue:[
-        isBlock == true ifTrue:[
-            '[] in ' printOn:aStream
-        ].
-        receiver name printOn:aStream.
-        (class notNil and:[class ~~ receiver class]) ifTrue:[
-            '>>' printOn:aStream.
-            class name printOn:aStream
-        ].
-        aStream space.
-        selector printOn:aStream.
-        aStream space.
+	isBlock == true ifTrue:[
+	    '[] in ' printOn:aStream
+	].
+	receiver name printOn:aStream.
+	(class notNil and:[class ~~ receiver class]) ifTrue:[
+	    '>>' printOn:aStream.
+	    class name printOn:aStream
+	].
+	aStream space.
+	selector printOn:aStream.
+	aStream space.
 
-        aStream nextPutAll:'(total '.
-        totalTally printOn:aStream.
-        aStream nextPutAll:'%)'.
+	aStream nextPutAll:'(total '.
+	totalTally printOn:aStream.
+	aStream nextPutAll:'%)'.
 
-        leafTally notNil ifTrue:[
-            aStream nextPutAll:'(leaf '.
-            leafTally printOn:aStream.
-            aStream nextPutAll:'%)'.
-        ].
+	leafTally notNil ifTrue:[
+	    aStream nextPutAll:'(leaf '.
+	    leafTally printOn:aStream.
+	    aStream nextPutAll:'%)'.
+	].
     ].
 !
 
@@ -65,10 +74,10 @@
     leafNodes := OrderedCollection new.
     self addLeafNodesTo:leafNodes.
     leafNodes := leafNodes asSortedCollection:[:a :b |
-                                        a leafTally < b leafTally].
+					a leafTally < b leafTally].
     leafNodes do:[:aNode |
-        aNode printSingleOn:aStream.
-        aStream cr.
+	aNode printSingleOn:aStream.
+	aStream cr.
     ].
 ! !
 
@@ -121,13 +130,13 @@
 computePercentage:total
     totalTally := (totalTally / total * 1000) rounded / 10.0.
     leafTally notNil ifTrue:[
-        leafTally := (leafTally / total * 1000) rounded / 10.0
+	leafTally := (leafTally / total * 1000) rounded / 10.0
     ].
 
     called notNil ifTrue:[
-        called do:[:subTree |
-            subTree computePercentage:total
-        ]
+	called do:[:subTree |
+	    subTree computePercentage:total
+	]
     ].
 !
 
@@ -202,21 +211,21 @@
     |idx|
 
     leafTally notNil ifTrue:[
-        idx := aCollection  indexOf:self.
-        idx == 0 ifTrue:[
-            aCollection add:self copy
-        ] ifFalse:[
-            |nd|
+	idx := aCollection  indexOf:self.
+	idx == 0 ifTrue:[
+	    aCollection add:self copy
+	] ifFalse:[
+	    |nd|
 
-            nd := aCollection at:idx.
-            nd leafTally:(nd leafTally + leafTally).
-            nd totalTally:(nd totalTally + totalTally)
-        ]
+	    nd := aCollection at:idx.
+	    nd leafTally:(nd leafTally + leafTally).
+	    nd totalTally:(nd totalTally max: totalTally)
+	]
     ].
     called notNil ifTrue:[
-        called do:[:aNode |
-            aNode addLeafNodesTo:aCollection
-        ]
+	called do:[:aNode |
+	    aNode addLeafNodesTo:aCollection
+	]
     ]
 !
 
@@ -226,4 +235,3 @@
     class ~~ aProfileTreeNode methodClass ifTrue:[^ false].
     ^ true
 ! !
-