author | Claus Gittinger <cg@exept.de> |
Fri, 19 Jan 2018 23:42:23 +0100 | |
changeset 17952 | b78dac4d2a4c |
parent 12026 | 8ab9fdf1d225 |
child 12401 | 4714b9640528 |
permissions | -rw-r--r-- |
9991 | 1 |
" |
10060 | 2 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague |
3 |
All Rights Reserved |
|
9991 | 4 |
|
10060 | 5 |
Permission is hereby granted, free of charge, to any person |
6 |
obtaining a copy of this software and associated documentation |
|
7 |
files (the 'Software'), to deal in the Software without |
|
8 |
restriction, including without limitation the rights to use, |
|
9 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
10 |
copies of the Software, and to permit persons to whom the |
|
11 |
Software is furnished to do so, subject to the following |
|
12 |
conditions: |
|
13 |
||
14 |
The above copyright notice and this permission notice shall be |
|
15 |
included in all copies or substantial portions of the Software. |
|
16 |
||
17 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
18 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
19 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
20 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
21 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
22 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
23 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
24 |
OTHER DEALINGS IN THE SOFTWARE. |
|
9991 | 25 |
" |
26 |
"{ Package: 'stx:libtool' }" |
|
27 |
||
28 |
"{ NameSpace: Tools }" |
|
29 |
||
30 |
MessageTally subclass:#Profiler |
|
12023
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
31 |
instanceVariableNames:'startTimestamp notes retVal' |
9991 | 32 |
classVariableNames:'' |
33 |
poolDictionaries:'' |
|
34 |
category:'Interface-Browsers-New-Profiler' |
|
35 |
! |
|
36 |
||
37 |
!Profiler class methodsFor:'documentation'! |
|
38 |
||
39 |
copyright |
|
40 |
" |
|
10060 | 41 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague |
42 |
All Rights Reserved |
|
43 |
||
44 |
Permission is hereby granted, free of charge, to any person |
|
45 |
obtaining a copy of this software and associated documentation |
|
46 |
files (the 'Software'), to deal in the Software without |
|
47 |
restriction, including without limitation the rights to use, |
|
48 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
49 |
copies of the Software, and to permit persons to whom the |
|
50 |
Software is furnished to do so, subject to the following |
|
51 |
conditions: |
|
9991 | 52 |
|
10060 | 53 |
The above copyright notice and this permission notice shall be |
54 |
included in all copies or substantial portions of the Software. |
|
55 |
||
56 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
57 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
58 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
59 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
60 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
61 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
62 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
63 |
OTHER DEALINGS IN THE SOFTWARE. |
|
9991 | 64 |
" |
65 |
! |
|
66 |
||
12026 | 67 |
documentation |
68 |
" |
|
69 |
a visual profiler; |
|
70 |
provides the same interface as a MessageTally, but does not show the |
|
71 |
sample data on a stream, instead a browser is opened, allowing easy |
|
72 |
navigation through the sampled code. |
|
73 |
" |
|
74 |
! |
|
75 |
||
12023
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
76 |
examples |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
77 |
" |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
78 |
[exBegin] |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
79 |
| profiler | |
9991 | 80 |
|
12023
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
81 |
profiler := Tools::Profiler profileOn:[1 to: 1000 do:[:i|i factorial]] interval: 10. |
9991 | 82 |
Tools::NewSystemBrowser browseProfilerStatistics: profiler |
12023
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
83 |
[exEnd] |
9991 | 84 |
|
12023
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
85 |
[exBegin] |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
86 |
Tools::Profiler spyOn:[1 to: 1000 do:[:i|i factorial]] interval: 10. |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
87 |
[exEnd] |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
88 |
|
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
89 |
" |
9991 | 90 |
! ! |
91 |
||
92 |
!Profiler class methodsFor:'instance creation'! |
|
93 |
||
94 |
readStatisticsFrom: stream |
|
95 |
||
96 |
^BinaryInputManager readFrom: stream |
|
97 |
||
98 |
"Created: / 24-11-2007 / 09:24:12 / janfrog" |
|
99 |
! ! |
|
100 |
||
12023
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
101 |
!Profiler class methodsFor:'messageTally compatible interface'! |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
102 |
|
12024 | 103 |
spyDetailedOn: aBlock |
12023
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
104 |
"execute a Block; then open a visual profiler. |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
105 |
Return the value from aBlock" |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
106 |
|
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
107 |
^ self spyOn:aBlock interval:(self detailedSamplingIntervalMS) |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
108 |
! |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
109 |
|
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
110 |
spyOn: aBlock |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
111 |
"execute a Block; then open a visual profiler. |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
112 |
Return the value from aBlock" |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
113 |
|
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
114 |
^ self spyOn:aBlock interval:(self normalSamplingIntervalMS) |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
115 |
! |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
116 |
|
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
117 |
spyOn: aBlock interval: interval |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
118 |
"execute a Block; then open a visual profiler. |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
119 |
Return the value from aBlock" |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
120 |
|
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
121 |
| profiler | |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
122 |
|
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
123 |
profiler := self new. |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
124 |
profiler profileOn:aBlock interval: interval. |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
125 |
Tools::NewSystemBrowser browseProfilerStatistics: profiler. |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
126 |
^ profiler retVal |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
127 |
! ! |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
128 |
|
9991 | 129 |
!Profiler class methodsFor:'profiling'! |
130 |
||
131 |
profile: aBlock |
|
12023
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
132 |
"run aBlock, return profile information" |
9991 | 133 |
|
12023
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
134 |
^self profileOn: aBlock |
9991 | 135 |
|
136 |
"Created: / 18-02-2008 / 20:24:08 / janfrog" |
|
137 |
! |
|
138 |
||
139 |
profileAndOpenBrowser: aBlock |
|
12023
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
140 |
"run aBlock, open a browser on the profile information; sample tick is 10ms" |
9991 | 141 |
|
12023
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
142 |
Tools::NewSystemBrowser browseProfilerStatistics: (self profile: aBlock) |
9991 | 143 |
|
144 |
" |
|
145 |
Tools::Profiler profileAndOpenBrowser:[ 10000 timesRepeat:[100 factorial] ] |
|
146 |
" |
|
147 |
||
148 |
"Created: / 18-02-2008 / 20:24:56 / janfrog" |
|
149 |
"Modified: / 18-02-2008 / 22:16:29 / janfrog" |
|
150 |
! |
|
151 |
||
12023
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
152 |
profileDetailedOn: aBlock |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
153 |
"run aBlock, return profile information; sample tick is 1ms" |
9991 | 154 |
|
12023
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
155 |
^self profileOn: aBlock interval:(self detailedSamplingIntervalMS) |
9991 | 156 |
|
157 |
"Created: / 24-11-2007 / 08:31:22 / janfrog" |
|
158 |
"Modified: / 25-12-2008 / 20:39:33 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
159 |
! |
|
160 |
||
12023
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
161 |
profileOn: aBlock |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
162 |
"run aBlock, return profile information; sample tick is 10ms" |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
163 |
|
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
164 |
^self profileOn: aBlock interval:(self normalSamplingIntervalMS) |
9991 | 165 |
|
12023
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
166 |
"Created: / 24-11-2007 / 08:31:22 / janfrog" |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
167 |
"Modified: / 25-12-2008 / 20:39:33 / Jan Vrany <vranyj1@fel.cvut.cz>" |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
168 |
! |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
169 |
|
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
170 |
profileOn: aBlock interval: interval |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
171 |
"run aBlock, return profile information; sample tick is interval (ms)" |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
172 |
|
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
173 |
^self new profileOn: aBlock interval: interval |
9991 | 174 |
|
175 |
"Created: / 24-11-2007 / 08:25:37 / janfrog" |
|
176 |
! ! |
|
177 |
||
178 |
!Profiler methodsFor:'I/O'! |
|
179 |
||
180 |
storeStatisticsOn: stream |
|
181 |
||
182 |
^BinaryOutputManager store: self on: stream |
|
183 |
||
184 |
"Created: / 24-11-2007 / 09:23:11 / janfrog" |
|
185 |
! ! |
|
186 |
||
187 |
!Profiler methodsFor:'accessing'! |
|
188 |
||
189 |
computationTime |
|
190 |
^ endTime - startTime |
|
191 |
||
192 |
"Created: / 24-11-2007 / 08:41:33 / janfrog" |
|
193 |
! |
|
194 |
||
195 |
notes |
|
196 |
^ notes |
|
197 |
||
198 |
"Created: / 24-11-2007 / 09:24:50 / janfrog" |
|
199 |
! |
|
200 |
||
201 |
notes:something |
|
202 |
notes := something. |
|
203 |
||
204 |
"Created: / 24-11-2007 / 09:24:50 / janfrog" |
|
205 |
! |
|
206 |
||
12023
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
207 |
retVal |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
208 |
^ retVal |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
209 |
! |
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
210 |
|
9991 | 211 |
startTimestamp |
212 |
^ startTimestamp |
|
213 |
||
214 |
"Created: / 24-11-2007 / 09:01:12 / janfrog" |
|
215 |
! ! |
|
216 |
||
217 |
!Profiler methodsFor:'profiling'! |
|
218 |
||
12023
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
219 |
profileOn: aBlock interval: interval |
9991 | 220 |
startTimestamp := Timestamp now. |
12023
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
221 |
retVal := super spyOn: aBlock interval: interval. |
9991 | 222 |
self nTally isZero ifFalse:[self tree computePercentage: self nTally]. |
12023
db541e9a6fc1
changed the protocol slightly to make it compatible with
Claus Gittinger <cg@exept.de>
parents:
10060
diff
changeset
|
223 |
^ self |
9991 | 224 |
|
225 |
"Created: / 24-11-2007 / 08:21:28 / janfrog" |
|
226 |
! ! |
|
227 |
||
228 |
!Profiler class methodsFor:'documentation'! |
|
229 |
||
12024 | 230 |
version |
12026 | 231 |
^ '$Header: /cvs/stx/stx/libtool/Tools__Profiler.st,v 1.5 2012-11-04 21:42:25 cg Exp $' |
12024 | 232 |
! |
233 |
||
9991 | 234 |
version_CVS |
12026 | 235 |
^ '$Header: /cvs/stx/stx/libtool/Tools__Profiler.st,v 1.5 2012-11-04 21:42:25 cg Exp $' |
9991 | 236 |
! |
237 |
||
238 |
version_SVN |
|
239 |
^ '§Id: Tools__Profiler.st 7486 2009-10-26 22:06:24Z vranyj1 §' |
|
240 |
! ! |