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