--- a/MessageTally.st Sat May 18 18:35:03 1996 +0200
+++ b/MessageTally.st Sat May 18 18:51:30 1996 +0200
@@ -39,20 +39,23 @@
statistic of method evaluation is output on Transcript.
To get statistic, use 'MessageTally spyOn:aBlock'.
- example:
- MessageTally spyOn:[
- (ByteArray uninitalizedNew:1000) sort
- ]
-
By default, probing is done every 10ms (i.e. the execution of the block is
interrupted every 10ms, and the context chain analyzed).
+
For better resolution, use smaller clock ticks (if your OperatingSystem
- supports it). Try spyDetailedOn:aBlock, which tries to measure things
- every 1ms. (Notice, that some OS's only provide a resolution of less than
- that time interval)
+ supports it). Try 'spyDetailedOn:aBlock', which tries to measure things
+ every 1ms.
+ (Notice, that some OS's do not provide this timer resolution,
+ so measuring may be less accurate.)
+
+ For good results, make certain that the measured block runs for some
+ time (say 5 seconds) - add a timesRepeat-loop around it if required.
[author:]
Claus Gittinger
+
+ [see also:]
+ CallChain
"
!
@@ -180,22 +183,39 @@
!MessageTally methodsFor:'accessing'!
nTally
- ^ ntally
+ "return the number of accumulated probes"
+
+ ^ ntally
+
+ "Modified: 18.5.1996 / 18:47:47 / cg"
!
tree
+ "return the accumulated calling tree"
+
^ tree
+
+ "Modified: 18.5.1996 / 18:47:57 / cg"
! !
!MessageTally methodsFor:'private'!
execute
+ "evaluate the target block"
+
theBlock value
+
+ "Modified: 18.5.1996 / 18:48:10 / cg"
! !
!MessageTally methodsFor:'probes'!
count:aContext
+ "entered whenever the probed block gets interrupted;
+ look where it is, and remember in the calling tree"
+
+ "{ Pragma: +optSpeed }"
+
|con chain info atEnd sender home|
con := aContext.
@@ -205,7 +225,7 @@
"walk up above the interrupt context"
[con receiver == Processor] whileTrue:[
- con := con sender
+ con := con sender
].
"got it - collect info from contexts"
@@ -217,66 +237,67 @@
atEnd := false.
[atEnd] whileFalse:[
- con isNil ifTrue:[
- atEnd := true
- ] ifFalse:[
- sender := con sender.
- sender isNil ifTrue:[
- atEnd := true
- ] ifFalse:[
- ((sender receiver == self) and:[sender selector == #execute]) ifTrue:[
- atEnd := true
+ con isNil ifTrue:[
+ atEnd := true
+ ] ifFalse:[
+ sender := con sender.
+ sender isNil ifTrue:[
+ atEnd := true
+ ] ifFalse:[
+ ((sender receiver == self) and:[sender selector == #execute]) ifTrue:[
+ atEnd := true
"/ ] ifFalse:[
"/ (sender isMemberOf:BlockContext) ifTrue:[
"/ sender sender selector == #execute ifTrue:[
"/ atEnd := true
"/ ]
"/ ]
- ]
- ]
- ].
- atEnd ifFalse:[
- info := CallChain new.
- (con isMemberOf:BlockContext) ifTrue:[
- home := con methodHome.
- home isNil ifTrue:[
- info receiver:UndefinedObject
- selector:'optimized'
- class:UndefinedObject.
- ] ifFalse:[
- info receiver:home receiver class
- selector:home selector
- class:con methodClass.
- ].
- info isBlock:true.
- ] ifFalse:[
- info receiver:con receiver class
- selector:con selector
- class:con methodClass.
- ].
- info rest:chain.
- chain := info.
- con := sender
- ]
+ ]
+ ]
+ ].
+ atEnd ifFalse:[
+ info := CallChain new.
+ (con isMemberOf:BlockContext) ifTrue:[
+ home := con methodHome.
+ home isNil ifTrue:[
+ info receiver:UndefinedObject
+ selector:'optimized'
+ class:UndefinedObject.
+ ] ifFalse:[
+ info receiver:home receiver class
+ selector:home selector
+ class:con methodClass.
+ ].
+ info isBlock:true.
+ ] ifFalse:[
+ info receiver:con receiver class
+ selector:con selector
+ class:con methodClass.
+ ].
+ info rest:chain.
+ chain := info.
+ con := sender
+ ]
].
"add chain to the tree"
chain isNil ifTrue:[^ self].
tree isNil ifTrue:[
- tree := ProfileTree new.
- tree receiver:MessageTally
- selector:#execute
- class:MessageTally .
+ tree := ProfileTree new.
+ tree receiver:MessageTally
+ selector:#execute
+ class:MessageTally .
].
tree addChain:chain
+
+ "Modified: 18.5.1996 / 18:48:45 / cg"
! !
!MessageTally methodsFor:'setup'!
-spyOn:aBlock interval:ms
- "spy on execution time"
+"spy on execution time"
|startTime endTime running delay|
@@ -315,6 +336,5 @@
!MessageTally class methodsFor:'documentation'!
-version
- ^ '$Header: /cvs/stx/stx/libbasic3/MessageTally.st,v 1.21 1996-05-18 16:35:03 cg Exp $'
+les/CVS/stx/libbasic3/MsgTally.st,v 1.21 1996/05/18 16:35:03 cg Exp $'
! !