author | Claus Gittinger <cg@exept.de> |
Tue, 23 Oct 2012 11:53:25 +0200 | |
changeset 2932 | eed4e9fc5400 |
parent 2281 | 859191db074f |
child 2970 | a040752cb070 |
permissions | -rw-r--r-- |
0 | 1 |
" |
21 | 2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
3 |
All Rights Reserved |
|
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
957 | 12 |
"{ Package: 'stx:libbasic3' }" |
13 |
||
120 | 14 |
Object subclass:#MessageTally |
571
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
15 |
instanceVariableNames:'tree probes ntally theBlock spyInterval executing startTime |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
16 |
endTime' |
236 | 17 |
classVariableNames:'' |
18 |
poolDictionaries:'' |
|
19 |
category:'System-Debugging-Support' |
|
0 | 20 |
! |
21 |
||
9 | 22 |
!MessageTally class methodsFor:'documentation'! |
23 |
||
88 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
27 |
All Rights Reserved |
|
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
9 | 36 |
! |
37 |
||
38 |
documentation |
|
39 |
" |
|
40 |
MessageTally allows profiling excution of a block; |
|
41 |
statistic of method evaluation is output on Transcript. |
|
42 |
To get statistic, use 'MessageTally spyOn:aBlock'. |
|
43 |
||
21 | 44 |
By default, probing is done every 10ms (i.e. the execution of the block is |
45 |
interrupted every 10ms, and the context chain analyzed). |
|
260 | 46 |
|
21 | 47 |
For better resolution, use smaller clock ticks (if your OperatingSystem |
260 | 48 |
supports it). Try 'spyDetailedOn:aBlock', which tries to measure things |
49 |
every 1ms. |
|
50 |
(Notice, that some OS's do not provide this timer resolution, |
|
51 |
so measuring may be less accurate.) |
|
52 |
||
53 |
For good results, make certain that the measured block runs for some |
|
54 |
time (say 5 seconds) - add a timesRepeat-loop around it if required. |
|
236 | 55 |
|
561 | 56 |
The displayed information is: |
57 |
- the calling tree augmented with total and leaf times. |
|
58 |
the leaf time is the time spent in the method itself; |
|
59 |
the total time is the time spent in the method and all of its called |
|
60 |
methods. |
|
61 |
||
62 |
- the leaf methods by receiver |
|
63 |
this lists the leaf nodes only, sorted by time spent there. |
|
64 |
Here, method invocations for different receiver types are |
|
65 |
listed separately. |
|
66 |
||
67 |
- the leaf methods |
|
68 |
this lists the leaf nodes only, sorted by time spent there. |
|
69 |
Here, method invocations for different receiver types are |
|
70 |
summed up separately. |
|
71 |
||
594 | 72 |
The last list (leaf methods) is propably the most interesting; |
73 |
if you are only interested in that (or the calling hierarchy is too |
|
565
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
74 |
deep for the list to be useful or the amount of data to be handled |
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
75 |
correctly), use a leaf-spy with: |
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
76 |
MessageTally spyLeafOn:aBlock |
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
77 |
This only accumulates statistics about methods where the cpu time |
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
78 |
is actually spent (not collecing hierarchy information). |
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
79 |
|
561 | 80 |
|
236 | 81 |
[author:] |
82 |
Claus Gittinger |
|
260 | 83 |
|
84 |
[see also:] |
|
261 | 85 |
CallChain ProfileTree |
86 |
MessageTracer |
|
21 | 87 |
" |
88 |
! |
|
89 |
||
90 |
examples |
|
9 | 91 |
" |
565
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
92 |
the block must execute for a while; |
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
93 |
otherwise, no probes (and therefore no statistics) can |
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
94 |
be gathered: |
244 | 95 |
[exBegin] |
264 | 96 |
MessageTally spyOn:[ #(6 5 4 3 2 1) sort ] |
244 | 97 |
[exEnd] |
98 |
||
99 |
||
565
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
100 |
if required, execute the block in a loop; |
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
101 |
however, for the example below, a larger repeat count |
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
102 |
is required, for a reasonable measurement: |
244 | 103 |
[exBegin] |
259 | 104 |
MessageTally spyOn:[ |
264 | 105 |
10000 timesRepeat:[ #(6 5 4 3 2 1) sort] |
259 | 106 |
] |
244 | 107 |
[exEnd] |
108 |
||
109 |
||
565
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
110 |
thats better: |
244 | 111 |
[exBegin] |
259 | 112 |
MessageTally spyOn:[ |
264 | 113 |
100000 timesRepeat:[ #(6 5 4 3 2 1) sort] |
259 | 114 |
] |
244 | 115 |
[exEnd] |
116 |
||
117 |
||
565
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
118 |
thats much better |
244 | 119 |
[exBegin] |
259 | 120 |
MessageTally spyOn:[ |
264 | 121 |
500000 timesRepeat:[#(6 5 4 3 2 1) sort] |
259 | 122 |
] |
244 | 123 |
[exEnd] |
124 |
||
125 |
||
565
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
126 |
a smaller probing tick also helps: |
244 | 127 |
[exBegin] |
259 | 128 |
MessageTally spyDetailedOn:[ |
570
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
129 |
500000 timesRepeat:[(10 to:1 by:-1) asArray reverse] |
259 | 130 |
] |
244 | 131 |
[exEnd] |
132 |
||
21 | 133 |
|
565
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
134 |
as usual, measurements add some extra overhead; |
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
135 |
compare the above time to the time given by: |
244 | 136 |
[exBegin] |
565
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
137 |
Transcript showCR:( |
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
138 |
Time millisecondsToRun:[ |
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
139 |
500000 timesRepeat:[#(6 5 4 3 2 1) sort] |
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
140 |
] |
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
141 |
) |
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
142 |
[exEnd] |
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
143 |
probing the leafs only may help to reduce the overhead |
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
144 |
a bit: |
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
145 |
[exBegin] |
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
146 |
MessageTally spyLeafDetailedOn:[ |
264 | 147 |
500000 timesRepeat:[#(6 5 4 3 2 1) sort] |
259 | 148 |
] |
244 | 149 |
[exEnd] |
150 |
||
151 |
||
565
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
152 |
|
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
153 |
|
244 | 154 |
[exBegin] |
21 | 155 |
MessageTally spyOn:[SystemBrowser open ] |
244 | 156 |
[exEnd] |
157 |
||
158 |
||
159 |
[exBegin] |
|
21 | 160 |
MessageTally spyDetailedOn:[SystemBrowser open ] |
244 | 161 |
[exEnd] |
21 | 162 |
" |
9 | 163 |
! ! |
0 | 164 |
|
1280 | 165 |
!MessageTally class methodsFor:'spying-private'! |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
166 |
|
570
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
167 |
spyLeafOn:aBlock interval:ms to:outStream |
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
168 |
"evaluate aBlock and output leaf method statistics on outStream" |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
169 |
|
571
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
170 |
|aTally| |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
171 |
|
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
172 |
aTally := self new. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
173 |
|
571
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
174 |
[ |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
175 |
[ |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
176 |
aTally spyLeafOn:aBlock interval:ms. |
1152
b1f95f16a0a4
Use #ifCurtailed: instead of #valueOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents:
1139
diff
changeset
|
177 |
] ifCurtailed:[ |
571
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
178 |
outStream nextPutLine:'TALLY: block returned'. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
179 |
] |
1139
56861678ff27
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
180 |
] ensure:[ |
571
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
181 |
aTally printLeafStatisticOn:outStream |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
182 |
]. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
183 |
|
571
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
184 |
"Modified: 22.3.1997 / 16:50:47 / cg" |
88 | 185 |
! |
186 |
||
570
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
187 |
spyOn:aBlock interval:ms to:outStream |
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
188 |
"evaluate aBlock and output full statistics on outstream" |
0 | 189 |
|
2249 | 190 |
|aTally retVal| |
0 | 191 |
|
192 |
aTally := self new. |
|
21 | 193 |
|
571
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
194 |
[ |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
195 |
[ |
2249 | 196 |
retVal := aTally spyOn:aBlock interval:ms. |
1152
b1f95f16a0a4
Use #ifCurtailed: instead of #valueOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents:
1139
diff
changeset
|
197 |
] ifCurtailed:[ |
571
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
198 |
outStream nextPutLine:'TALLY: block returned'. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
199 |
] |
1139
56861678ff27
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
200 |
] ensure:[ |
571
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
201 |
aTally printFullStatisticOn:outStream |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
202 |
]. |
2249 | 203 |
^ retVal |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
204 |
|
571
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
205 |
"Modified: 22.3.1997 / 16:54:36 / cg" |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
206 |
! ! |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
207 |
|
1280 | 208 |
!MessageTally class methodsFor:'spying-public interface'! |
570
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
209 |
|
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
210 |
spyDetailedOn:aBlock |
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
211 |
"evaluate aBlock and output full statistics on the Transcript. |
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
212 |
The Tick is 1ms for more detailed measurement. |
1376 | 213 |
Notice: not all architectures support such a small timer interval." |
570
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
214 |
|
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
215 |
^ self spyOn:aBlock interval:1 to:Transcript |
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
216 |
|
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
217 |
"Modified: 22.3.1997 / 16:26:39 / cg" |
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
218 |
! |
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
219 |
|
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
220 |
spyLeafDetailedOn:aBlock |
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
221 |
"evaluate aBlock and output leaf method statistics on the Transcript. |
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
222 |
The Tick is 1ms for more detailed measurement. |
1376 | 223 |
Notice: not all architectures support such a small timer interval." |
570
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
224 |
|
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
225 |
^ self spyLeafOn:aBlock interval:1 to:Transcript |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
226 |
|
570
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
227 |
"Created: 20.3.1997 / 20:41:53 / cg" |
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
228 |
"Modified: 22.3.1997 / 16:26:47 / cg" |
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
229 |
! |
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
230 |
|
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
231 |
spyLeafOn:aBlock |
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
232 |
"evaluate aBlock and output leaf method statistics on the Transcript. |
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
233 |
The Tick is 10ms for less detailed measurements." |
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
234 |
|
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
235 |
^ self spyLeafOn:aBlock interval:10 to:Transcript |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
236 |
|
570
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
237 |
"Created: 20.3.1997 / 20:41:40 / cg" |
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
238 |
"Modified: 22.3.1997 / 16:26:49 / cg" |
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
239 |
! |
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
240 |
|
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
241 |
spyOn:aBlock |
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
242 |
"evaluate aBlock and output full statistics on the Transcript. |
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
243 |
The Tick is 10ms for less detailed measurements." |
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
244 |
|
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
245 |
^ self spyOn:aBlock interval:10 to:Transcript |
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
246 |
|
9c3efb856ee6
allow spy output to be sent to some stream
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
247 |
"Modified: 22.3.1997 / 16:26:51 / cg" |
88 | 248 |
! ! |
249 |
||
250 |
!MessageTally methodsFor:'accessing'! |
|
251 |
||
571
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
252 |
endTime |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
253 |
"return the endTime of the run" |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
254 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
255 |
^ endTime |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
256 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
257 |
"Modified: 18.5.1996 / 18:47:47 / cg" |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
258 |
"Created: 22.3.1997 / 16:44:29 / cg" |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
259 |
! |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
260 |
|
88 | 261 |
nTally |
260 | 262 |
"return the number of accumulated probes" |
263 |
||
264 |
^ ntally |
|
265 |
||
266 |
"Modified: 18.5.1996 / 18:47:47 / cg" |
|
0 | 267 |
! |
268 |
||
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
269 |
probes |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
270 |
"return the accumulated collection of flat probes" |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
271 |
|
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
272 |
^ probes |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
273 |
|
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
274 |
"Modified: 18.5.1996 / 18:47:57 / cg" |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
275 |
"Created: 20.3.1997 / 20:54:19 / cg" |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
276 |
! |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
277 |
|
571
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
278 |
startTime |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
279 |
"return the startTime of the run" |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
280 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
281 |
^ startTime |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
282 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
283 |
"Modified: 18.5.1996 / 18:47:47 / cg" |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
284 |
"Created: 22.3.1997 / 16:44:33 / cg" |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
285 |
! |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
286 |
|
88 | 287 |
tree |
260 | 288 |
"return the accumulated calling tree" |
289 |
||
88 | 290 |
^ tree |
260 | 291 |
|
292 |
"Modified: 18.5.1996 / 18:47:57 / cg" |
|
0 | 293 |
! ! |
294 |
||
963 | 295 |
!MessageTally methodsFor:'printing & storing'! |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
296 |
|
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
297 |
printFlatMethodLeafsOn:aStream |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
298 |
"print all flat method leafNodes statistics on aStream" |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
299 |
|
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
300 |
|leafNodes| |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
301 |
|
567
180b5d0da74b
combine multiple invocations of the same method
Claus Gittinger <cg@exept.de>
parents:
565
diff
changeset
|
302 |
leafNodes := OrderedCollection new. |
180b5d0da74b
combine multiple invocations of the same method
Claus Gittinger <cg@exept.de>
parents:
565
diff
changeset
|
303 |
probes do:[:aProbe | aProbe addMethodLeafNodesTo:leafNodes]. |
180b5d0da74b
combine multiple invocations of the same method
Claus Gittinger <cg@exept.de>
parents:
565
diff
changeset
|
304 |
leafNodes := leafNodes asSortedCollection:[:a :b | |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
305 |
a leafTally < b leafTally]. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
306 |
leafNodes do:[:aNode | |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
307 |
aNode leafTally ~= 0 ifTrue:[ |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
308 |
aNode printSingleMethodLeafOn:aStream. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
309 |
aStream cr. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
310 |
] |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
311 |
]. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
312 |
|
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
313 |
"Created: 20.3.1997 / 20:56:13 / cg" |
567
180b5d0da74b
combine multiple invocations of the same method
Claus Gittinger <cg@exept.de>
parents:
565
diff
changeset
|
314 |
"Modified: 21.3.1997 / 10:18:31 / cg" |
571
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
315 |
! |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
316 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
317 |
printFullStatisticOn:outStream |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
318 |
"output full statistics on outstream" |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
319 |
|
589 | 320 |
|runTime err| |
571
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
321 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
322 |
ntally == 0 ifTrue:[ |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
323 |
self printNoProbesOn:outStream. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
324 |
^ self |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
325 |
]. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
326 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
327 |
tree computePercentage:ntally. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
328 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
329 |
runTime := endTime - startTime. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
330 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
331 |
outStream cr. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
332 |
err := (1000 // ntally / 10.0). |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
333 |
err > 0 ifTrue:[ |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
334 |
outStream nextPutLine:('total execution time: ' |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
335 |
, runTime printString , ' ms ' |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
336 |
, '(' , ntally printString , ' probes ;' |
770 | 337 |
, ' error ' |
571
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
338 |
, (1000 // ntally / 10.0) printString |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
339 |
, '%)' |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
340 |
). |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
341 |
] ifFalse:[ |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
342 |
outStream nextPutLine:('total execution time: ' |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
343 |
, runTime printString , ' ms ' |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
344 |
, '(' , ntally printString , ' probes)' |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
345 |
). |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
346 |
]. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
347 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
348 |
outStream cr. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
349 |
tree printOn:outStream. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
350 |
outStream cr; cr. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
351 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
352 |
outStream nextPutLine:'leafs of calling tree (by receiver & implementing method):'. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
353 |
outStream cr. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
354 |
tree printLeafsOn:outStream. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
355 |
outStream cr; cr. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
356 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
357 |
outStream nextPutLine:'method leafs of calling tree (by implementing method only):'. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
358 |
outStream cr. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
359 |
tree printMethodLeafsOn:outStream. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
360 |
outStream cr; cr. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
361 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
362 |
"Created: 22.3.1997 / 16:52:09 / cg" |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
363 |
"Modified: 22.3.1997 / 16:53:38 / cg" |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
364 |
! |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
365 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
366 |
printLeafStatisticOn:outStream |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
367 |
"output leaf statistics on outstream" |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
368 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
369 |
|runTime err| |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
370 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
371 |
ntally == 0 ifTrue:[ |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
372 |
self printNoProbesOn:outStream. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
373 |
^ self. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
374 |
]. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
375 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
376 |
runTime := endTime - startTime. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
377 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
378 |
probes do:[:aProbe | |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
379 |
aProbe computePercentage:ntally |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
380 |
]. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
381 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
382 |
outStream cr. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
383 |
err := (1000 // ntally / 10.0). |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
384 |
err > 0 ifTrue:[ |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
385 |
outStream nextPutLine:('total execution time: ' |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
386 |
, runTime printString , ' ms ' |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
387 |
, '(' , ntally printString , ' probes ;' |
770 | 388 |
, ' error ' |
571
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
389 |
, (1000 // ntally / 10.0) printString |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
390 |
, '%)' |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
391 |
). |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
392 |
] ifFalse:[ |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
393 |
outStream nextPutLine:('total execution time: ' |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
394 |
, runTime printString , ' ms ' |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
395 |
, '(' , ntally printString , ' probes)' |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
396 |
). |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
397 |
]. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
398 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
399 |
outStream nextPutLine:'method leafs of calling tree:'. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
400 |
outStream cr. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
401 |
self printFlatMethodLeafsOn:outStream. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
402 |
outStream cr; cr. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
403 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
404 |
"Created: 22.3.1997 / 16:50:06 / cg" |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
405 |
"Modified: 22.3.1997 / 16:53:15 / cg" |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
406 |
! |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
407 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
408 |
printNoProbesOn:outStream |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
409 |
"output a message that no probes are present" |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
410 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
411 |
outStream cr. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
412 |
outStream nextPutLine:'TALLY: No probes - execution time too short;'. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
413 |
outStream nextPutLine:'TALLY: retry using: spyOn:[n timesRepeat:[...]]'. |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
414 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
415 |
"Created: 22.3.1997 / 16:53:23 / cg" |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
416 |
! ! |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
417 |
|
0 | 418 |
!MessageTally methodsFor:'private'! |
419 |
||
21 | 420 |
execute |
260 | 421 |
"evaluate the target block" |
422 |
||
565
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
423 |
executing := true. |
2249 | 424 |
^ theBlock value |
260 | 425 |
|
565
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
426 |
"Modified: 20.3.1997 / 21:36:27 / cg" |
21 | 427 |
! ! |
0 | 428 |
|
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
429 |
!MessageTally methodsFor:'probing'! |
21 | 430 |
|
431 |
count:aContext |
|
260 | 432 |
"entered whenever the probed block gets interrupted; |
433 |
look where it is, and remember in the calling tree" |
|
434 |
||
263 | 435 |
"{ Pragma: +optSpeed }" |
436 |
||
2281 | 437 |
|chain| |
0 | 438 |
|
2281 | 439 |
chain := CallChain |
440 |
callChainTo:aContext |
|
441 |
stopAtCallerForWhich:[:con | |
|
442 |
(con receiver == self) and:[con selector == #execute] |
|
443 |
]. |
|
0 | 444 |
|
2281 | 445 |
"add chain to the tree" |
446 |
||
447 |
chain notNil ifTrue:[ |
|
448 |
ntally := ntally + 1. |
|
449 |
tree addChain:chain |
|
0 | 450 |
]. |
451 |
||
2281 | 452 |
"Modified: / 04-07-2010 / 09:45:28 / cg" |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
453 |
! |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
454 |
|
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
455 |
countLeaf:aContext |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
456 |
"entered whenever the probed block gets interrupted; |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
457 |
look where it is, and remember in the flat profile" |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
458 |
|
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
459 |
"{ Pragma: +optSpeed }" |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
460 |
|
2281 | 461 |
|con entry recClass selector mthdClass sender home existingEntry| |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
462 |
|
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
463 |
con := aContext. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
464 |
con isNil ifTrue:[^ self]. |
0 | 465 |
|
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
466 |
"walk up above the interrupt context" |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
467 |
|
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
468 |
[con receiver == Processor] whileTrue:[ |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
469 |
con := con sender |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
470 |
]. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
471 |
|
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
472 |
"got it - collect info from contexts" |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
473 |
|
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
474 |
con isNil ifTrue:[^ self]. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
475 |
((con receiver == self) and:[con selector == #execute]) ifTrue:[^ self]. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
476 |
|
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
477 |
sender := con sender. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
478 |
sender isNil ifTrue:[^ self]. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
479 |
((sender receiver == self) and:[sender selector == #execute]) ifTrue:[^ self]. |
88 | 480 |
|
2281 | 481 |
home := con methodHome. |
482 |
home isNil ifTrue:[ |
|
483 |
recClass := UndefinedObject. |
|
484 |
selector := 'optimized'. |
|
485 |
mthdClass := UndefinedObject. |
|
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
486 |
] ifFalse:[ |
2281 | 487 |
recClass := home receiver class. |
488 |
selector := home selector. |
|
489 |
mthdClass := home methodClass. |
|
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
490 |
]. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
491 |
|
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
492 |
"add info to the probes collection" |
88 | 493 |
|
565
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
494 |
ntally := ntally + 1. |
01241f73a7a0
dont increment tally for ignored contexts.
Claus Gittinger <cg@exept.de>
parents:
564
diff
changeset
|
495 |
|
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
496 |
entry := ProfileTree new. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
497 |
entry |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
498 |
receiver:recClass |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
499 |
selector:selector |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
500 |
class:mthdClass |
2281 | 501 |
isBlock:(con isBlockContext). |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
502 |
|
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
503 |
existingEntry := probes elementAt:entry ifAbsent:nil. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
504 |
existingEntry isNil ifTrue:[ |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
505 |
probes add:entry |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
506 |
] ifFalse:[ |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
507 |
existingEntry incrementLeafTally. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
508 |
]. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
509 |
|
2281 | 510 |
"Modified: / 04-07-2010 / 09:47:06 / cg" |
571
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
511 |
! ! |
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
512 |
|
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
513 |
!MessageTally methodsFor:'spy setup'! |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
514 |
|
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
515 |
spyLeafOn:aBlock interval:ms |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
516 |
"spy on execution time; generate information on leaf nodes only" |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
517 |
|
571
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
518 |
|probing delay probingProcess probedProcess| |
88 | 519 |
|
520 |
theBlock := aBlock. |
|
521 |
||
1439 | 522 |
Processor activeProcess withPriority:(Processor userInterruptPriority-1) do:[ |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
523 |
|
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
524 |
probingProcess := [ |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
525 |
|p| |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
526 |
|
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
527 |
p := probedProcess. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
528 |
[probing] whileTrue:[ |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
529 |
delay wait. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
530 |
executing ifTrue:[ |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
531 |
self countLeaf:p suspendedContext |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
532 |
] |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
533 |
]. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
534 |
] newProcess. |
88 | 535 |
|
1439 | 536 |
probingProcess priority:(Processor userInterruptPriority+1). |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
537 |
|
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
538 |
delay := (Delay forMilliseconds:ms). |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
539 |
ntally := 0. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
540 |
probes := Set new:200. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
541 |
|
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
542 |
probedProcess := Processor activeProcess. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
543 |
|
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
544 |
executing := false. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
545 |
probing := true. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
546 |
probingProcess resume. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
547 |
|
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
548 |
[ |
263 | 549 |
startTime := OperatingSystem getMillisecondTime. |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
550 |
self execute. |
1139
56861678ff27
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
963
diff
changeset
|
551 |
] ensure:[ |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
552 |
probing := executing := false. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
553 |
theBlock := nil. |
571
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
554 |
endTime := OperatingSystem getMillisecondTime. |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
555 |
]. |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
556 |
]. |
88 | 557 |
|
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
558 |
"Created: 20.3.1997 / 20:15:07 / cg" |
571
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
559 |
"Modified: 22.3.1997 / 16:46:42 / cg" |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
560 |
! |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
561 |
|
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
562 |
spyOn:aBlock interval:ms |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
563 |
"spy on execution time, generate a hierarchical call information" |
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
564 |
|
2932 | 565 |
|probing delay probingProcess probedProcess retVal runPrio probePrio| |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
566 |
|
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
567 |
theBlock := aBlock. |
2932 | 568 |
runPrio := (Processor activePriority-1 "userInterruptPriority-1"). |
569 |
probePrio := (Processor activePriority"+1" "Processor userInterruptPriority+1"). |
|
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
570 |
|
2249 | 571 |
Processor activeProcess |
2932 | 572 |
withPriority:runPrio |
2249 | 573 |
do:[ |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
574 |
|
2249 | 575 |
probingProcess := [ |
576 |
|p| |
|
88 | 577 |
|
2249 | 578 |
p := probedProcess. |
579 |
[probing] whileTrue:[ |
|
2932 | 580 |
delay wait. |
2249 | 581 |
executing ifTrue:[ |
582 |
self count:p suspendedContext |
|
583 |
] |
|
584 |
]. |
|
585 |
] newProcess. |
|
88 | 586 |
|
2932 | 587 |
probingProcess priority:probePrio. |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
588 |
|
2249 | 589 |
delay := (Delay forMilliseconds:ms). |
590 |
ntally := 0. |
|
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
591 |
|
2249 | 592 |
tree := ProfileTree new. |
593 |
tree |
|
594 |
receiver:MessageTally |
|
595 |
selector:#execute |
|
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
596 |
class:MessageTally |
2249 | 597 |
isBlock:false. |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
598 |
|
2249 | 599 |
probedProcess := Processor activeProcess. |
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
600 |
|
2249 | 601 |
executing := false. |
602 |
probing := true. |
|
603 |
probingProcess resume. |
|
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
604 |
|
2249 | 605 |
[ |
606 |
startTime := OperatingSystem getMillisecondTime. |
|
607 |
retVal := self execute. |
|
608 |
] ensure:[ |
|
609 |
probing := executing := false. |
|
610 |
theBlock := nil. |
|
611 |
endTime := OperatingSystem getMillisecondTime. |
|
612 |
]. |
|
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
613 |
]. |
2249 | 614 |
|
615 |
^ retVal |
|
263 | 616 |
|
564
d549f0b9c2f2
tallied block now executes under thisProcess;
Claus Gittinger <cg@exept.de>
parents:
561
diff
changeset
|
617 |
"Created: 20.3.1997 / 20:14:44 / cg" |
571
58e603e1ce24
made all print stuff instance methods;
Claus Gittinger <cg@exept.de>
parents:
570
diff
changeset
|
618 |
"Modified: 22.3.1997 / 16:45:42 / cg" |
88 | 619 |
! ! |
620 |
||
98 | 621 |
!MessageTally class methodsFor:'documentation'! |
622 |
||
261 | 623 |
version |
2932 | 624 |
^ '$Header: /cvs/stx/stx/libbasic3/MessageTally.st,v 1.47 2012-10-23 09:53:25 cg Exp $' |
2249 | 625 |
! |
626 |
||
627 |
version_CVS |
|
2932 | 628 |
^ '$Header: /cvs/stx/stx/libbasic3/MessageTally.st,v 1.47 2012-10-23 09:53:25 cg Exp $' |
98 | 629 |
! ! |