|
Class: MessageTally
Object
|
+--MessageTally
|
+--Tools::Profiler
- Package:
- stx:libbasic3
- Category:
- System-Debugging-Support
- Version:
- rev:
1.55
date: 2022/03/11 20:50:06
- user: cg
- file: MessageTally.st directory: libbasic3
- module: stx stc-classLibrary: libbasic3
MessageTally allows profiling excution of a block;
statistic of method evaluation is output on Transcript.
To get statistic, use 'MessageTally spyOn:aBlock'.
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 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.
The displayed information is:
- the calling tree augmented with total and leaf times.
the leaf time is the time spent in the method itself;
the total time is the time spent in the method and all of its called
methods.
- the leaf methods by receiver
this lists the leaf nodes only, sorted by time spent there.
Here, method invocations for different receiver types are
listed separately.
- the leaf methods
this lists the leaf nodes only, sorted by time spent there.
Here, method invocations for different receiver types are
summed up separately.
The last list (leaf methods) is propably the most interesting;
if you are only interested in that (or the calling hierarchy is too
deep for the list to be useful or the amount of data to be handled
correctly), use a leaf-spy with:
MessageTally spyLeafOn:aBlock
This only accumulates statistics about methods where the cpu time
is actually spent (not collecing hierarchy information).
copyrightCOPYRIGHT (c) 1995 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
constants
-
detailedSamplingIntervalMS
-
-
normalSamplingIntervalMS
-
spying-private
-
spyLeafOn: aBlock interval: ms to: outStream
-
evaluate aBlock and output leaf method statistics on outStream.
Return the value from aBlock.
-
spyOn: aBlock interval: ms to: outStream
-
evaluate aBlock and output full statistics on outstream.
Return the value from aBlock.
spying-public interface
-
spyDetailedOn: aBlock
-
evaluate aBlock and output full statistics on the Transcript.
The Tick is 1ms for more detailed measurement.
Notice: not all architectures support such a small timer interval.
-
spyLeafDetailedOn: aBlock
-
evaluate aBlock and output leaf method statistics on the Transcript.
The Tick is 1ms for more detailed measurement.
Notice: not all architectures support such a small timer interval.
-
spyLeafOn: aBlock
-
evaluate aBlock and output leaf method statistics on the Transcript.
The Tick is 10ms for less detailed measurements.
-
spyOn: aBlock
-
evaluate aBlock and output full statistics on the Transcript.
The Tick is 10ms for less detailed measurements.
accessing
-
endTime
-
return the endTime of the run
-
nTally
-
return the number of accumulated probes
-
probes
-
return the accumulated collection of flat probes
-
startTime
-
return the startTime of the run
-
tree
-
return the accumulated calling tree
printing & storing
-
printFlatMethodLeafsOn: aStream
-
print all flat method leafNodes statistics on aStream
-
printFullStatisticOn: outStream
-
output full statistics on outstream
-
printLeafStatisticOn: outStream
-
output leaf statistics on outstream
-
printNoProbesOn: outStream
-
output a message that no probes are present
private
-
execute
-
evaluate the target block
probing
-
count: aContext
-
entered whenever the probed block gets interrupted;
look where it is, and remember in the calling tree
-
count: aContext leafsOnly: leafsOnly
-
entered whenever the probed block gets interrupted;
look where it is, and remember in the calling tree or on the leaf-probe set
-
countLeaf: aContext
-
entered whenever the probed block gets interrupted;
look where it is, and remember in the flat profile
spy setup
-
spyLeafOn: aBlock interval: ms
-
spy on execution time; generate information on leaf nodes only
(which generates slightly less sampling overhead)
Return the value from aBlock.
-
spyOn: aBlock interval: ms
-
spy on execution time, generate a hierarchical call information on the output stream.
Return the value from aBlock.
-
spyOn: aBlock interval: ms leafsOnly: spyOnLeafsOnly
-
spy on execution time, either generate a hierarchical call information,
or leaf-node information.
Return the value from aBlock.
the block must execute for a while;
otherwise, no probes (and therefore no statistics) can
be gathered:
MessageTally spyOn:[ #(6 5 4 3 2 1) copy sort ]
|
if required, execute the block in a loop;
however, for the example below, a larger repeat count
is required, for a reasonable measurement:
MessageTally spyOn:[
10000 timesRepeat:[ #(6 5 4 3 2 1) copy sort]
]
|
that's better:
MessageTally spyOn:[
100000 timesRepeat:[ #(6 5 4 3 2 1) copy sort]
]
|
that's much better
MessageTally spyOn:[
500000 timesRepeat:[#(6 5 4 3 2 1) copy sort]
]
|
a smaller probing tick also helps:
MessageTally spyDetailedOn:[
500000 timesRepeat:[(10 to:1 by:-1) asArray reverse]
]
|
as usual, measurements add some extra overhead;
compare the above time to the time given by:
Transcript showCR:(
Time millisecondsToRun:[
500000 timesRepeat:[#(6 5 4 3 2 1) copy sort]
]
)
| probing the leafs only may help to reduce the overhead
a bit:
MessageTally spyLeafDetailedOn:[
500000 timesRepeat:[#(6 5 4 3 2 1) copy sort]
]
|
MessageTally spyOn:[SystemBrowser open ]
|
MessageTally spyDetailedOn:[SystemBrowser open ]
|
|