better summary display
authorClaus Gittinger <cg@exept.de>
Wed, 19 Mar 1997 12:40:49 +0100
changeset 559 8015fde9ae16
parent 558 931448e9af1e
child 560 50dc521a1a1d
better summary display
MessageTally.st
MsgTally.st
ProfileTree.st
--- a/MessageTally.st	Mon Mar 17 18:19:23 1997 +0100
+++ b/MessageTally.st	Wed Mar 19 12:40:49 1997 +0100
@@ -132,7 +132,7 @@
 spyOn:aBlock interval:ms
     "evaluate aBlock and output time statistic on Transcript"
 
-    |runTime aTally nTally|
+    |runTime aTally nTally err|
 
     aTally := self new.
     runTime := aTally spyOn:aBlock interval:ms.
@@ -145,21 +145,35 @@
         "/ aTally tree inspect.
         nTally := aTally nTally.
         Transcript cr.
-        Transcript showCR:('total execution time: '
-                           , runTime printString , ' ms '
-                           , '(' , nTally printString , ' probes ;'
-                           , ' error >= ' 
-                           , (1000 // nTally / 10.0) printString
-                           , '%)').
+        err := (1000 // nTally / 10.0).
+        err > 0 ifTrue:[
+            Transcript showCR:('total execution time: '
+                               , runTime printString , ' ms '
+                               , '(' , nTally printString , ' probes ;'
+                               , ' error >= ' 
+                               , (1000 // nTally / 10.0) printString
+                               , '%)'
+                              ).
+        ] ifFalse:[
+            Transcript showCR:('total execution time: '
+                               , runTime printString , ' ms '
+                               , '(' , nTally printString , ' probes)'
+                              ).
+        ].
+
         Transcript cr.
         aTally tree printOn:Transcript.
-        Transcript cr.
-        Transcript cr.
+        Transcript cr; cr.
 
-        Transcript showCR:'leafs of calling tree:'.
+        Transcript showCR:'leafs of calling tree (by receiver & implementing method):'.
         Transcript cr.
         aTally tree printLeafsOn:Transcript.
+        Transcript cr; cr.
+
+        Transcript showCR:'method leafs of calling tree (by implementing method only):'.
         Transcript cr.
+        aTally tree printMethodLeafsOn:Transcript.
+        Transcript cr; cr.
 
         "
         aTally statistics.
@@ -178,7 +192,7 @@
      Time millisecondsToRun:[500000 timesRepeat:[#(6 5 4 3 2 1) sort] ]
     "
 
-    "Modified: 18.5.1996 / 15:42:44 / cg"
+    "Modified: 19.3.1997 / 12:38:22 / cg"
 ! !
 
 !MessageTally methodsFor:'accessing'!
@@ -342,5 +356,5 @@
 !MessageTally class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic3/MessageTally.st,v 1.26 1996-05-18 17:21:20 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic3/MessageTally.st,v 1.27 1997-03-19 11:40:30 cg Exp $'
 ! !
--- a/MsgTally.st	Mon Mar 17 18:19:23 1997 +0100
+++ b/MsgTally.st	Wed Mar 19 12:40:49 1997 +0100
@@ -132,7 +132,7 @@
 spyOn:aBlock interval:ms
     "evaluate aBlock and output time statistic on Transcript"
 
-    |runTime aTally nTally|
+    |runTime aTally nTally err|
 
     aTally := self new.
     runTime := aTally spyOn:aBlock interval:ms.
@@ -145,21 +145,35 @@
         "/ aTally tree inspect.
         nTally := aTally nTally.
         Transcript cr.
-        Transcript showCR:('total execution time: '
-                           , runTime printString , ' ms '
-                           , '(' , nTally printString , ' probes ;'
-                           , ' error >= ' 
-                           , (1000 // nTally / 10.0) printString
-                           , '%)').
+        err := (1000 // nTally / 10.0).
+        err > 0 ifTrue:[
+            Transcript showCR:('total execution time: '
+                               , runTime printString , ' ms '
+                               , '(' , nTally printString , ' probes ;'
+                               , ' error >= ' 
+                               , (1000 // nTally / 10.0) printString
+                               , '%)'
+                              ).
+        ] ifFalse:[
+            Transcript showCR:('total execution time: '
+                               , runTime printString , ' ms '
+                               , '(' , nTally printString , ' probes)'
+                              ).
+        ].
+
         Transcript cr.
         aTally tree printOn:Transcript.
-        Transcript cr.
-        Transcript cr.
+        Transcript cr; cr.
 
-        Transcript showCR:'leafs of calling tree:'.
+        Transcript showCR:'leafs of calling tree (by receiver & implementing method):'.
         Transcript cr.
         aTally tree printLeafsOn:Transcript.
+        Transcript cr; cr.
+
+        Transcript showCR:'method leafs of calling tree (by implementing method only):'.
         Transcript cr.
+        aTally tree printMethodLeafsOn:Transcript.
+        Transcript cr; cr.
 
         "
         aTally statistics.
@@ -178,7 +192,7 @@
      Time millisecondsToRun:[500000 timesRepeat:[#(6 5 4 3 2 1) sort] ]
     "
 
-    "Modified: 18.5.1996 / 15:42:44 / cg"
+    "Modified: 19.3.1997 / 12:38:22 / cg"
 ! !
 
 !MessageTally methodsFor:'accessing'!
@@ -342,5 +356,5 @@
 !MessageTally class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic3/Attic/MsgTally.st,v 1.26 1996-05-18 17:21:20 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic3/Attic/MsgTally.st,v 1.27 1997-03-19 11:40:30 cg Exp $'
 ! !
--- 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 $'
 ! !