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
|
|
31 |
instanceVariableNames:'startTimestamp notes'
|
|
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 |
|
|
67 |
example1
|
|
68 |
|
|
69 |
| profiler |
|
|
70 |
profiler := Tools::Profiler spyOn:[1 to: 1000 do:[:i|i factorial]] interval: 10.
|
|
71 |
Tools::NewSystemBrowser browseProfilerStatistics: profiler
|
|
72 |
|
|
73 |
"
|
|
74 |
Profiler example1
|
|
75 |
"
|
|
76 |
! !
|
|
77 |
|
|
78 |
!Profiler class methodsFor:'instance creation'!
|
|
79 |
|
|
80 |
readStatisticsFrom: stream
|
|
81 |
|
|
82 |
^BinaryInputManager readFrom: stream
|
|
83 |
|
|
84 |
"Created: / 24-11-2007 / 09:24:12 / janfrog"
|
|
85 |
! !
|
|
86 |
|
|
87 |
!Profiler class methodsFor:'profiling'!
|
|
88 |
|
|
89 |
profile: aBlock
|
|
90 |
|
|
91 |
^self spyOn: aBlock
|
|
92 |
|
|
93 |
"Created: / 18-02-2008 / 20:24:08 / janfrog"
|
|
94 |
!
|
|
95 |
|
|
96 |
profileAndOpenBrowser: aBlock
|
|
97 |
|
|
98 |
Tools::NewSystemBrowser browseProfilerStatistics:
|
|
99 |
(self profile: aBlock)
|
|
100 |
|
|
101 |
"
|
|
102 |
Tools::Profiler profileAndOpenBrowser:[ 10000 timesRepeat:[100 factorial] ]
|
|
103 |
"
|
|
104 |
|
|
105 |
"Created: / 18-02-2008 / 20:24:56 / janfrog"
|
|
106 |
"Modified: / 18-02-2008 / 22:16:29 / janfrog"
|
|
107 |
!
|
|
108 |
|
|
109 |
spyOn: aBlock
|
|
110 |
|
|
111 |
^self spyOn: aBlock interval: 1
|
|
112 |
|
|
113 |
"Created: / 24-11-2007 / 08:31:22 / janfrog"
|
|
114 |
"Modified: / 25-12-2008 / 20:39:33 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
115 |
!
|
|
116 |
|
|
117 |
spyOn: aBlock interval: interval
|
|
118 |
|
|
119 |
^self new spyOn: aBlock interval: interval
|
|
120 |
|
|
121 |
"Created: / 24-11-2007 / 08:25:37 / janfrog"
|
|
122 |
! !
|
|
123 |
|
|
124 |
!Profiler methodsFor:'I/O'!
|
|
125 |
|
|
126 |
storeStatisticsOn: stream
|
|
127 |
|
|
128 |
^BinaryOutputManager store: self on: stream
|
|
129 |
|
|
130 |
"Created: / 24-11-2007 / 09:23:11 / janfrog"
|
|
131 |
! !
|
|
132 |
|
|
133 |
!Profiler methodsFor:'accessing'!
|
|
134 |
|
|
135 |
computationTime
|
|
136 |
^ endTime - startTime
|
|
137 |
|
|
138 |
"Created: / 24-11-2007 / 08:41:33 / janfrog"
|
|
139 |
!
|
|
140 |
|
|
141 |
notes
|
|
142 |
^ notes
|
|
143 |
|
|
144 |
"Created: / 24-11-2007 / 09:24:50 / janfrog"
|
|
145 |
!
|
|
146 |
|
|
147 |
notes:something
|
|
148 |
notes := something.
|
|
149 |
|
|
150 |
"Created: / 24-11-2007 / 09:24:50 / janfrog"
|
|
151 |
!
|
|
152 |
|
|
153 |
startTimestamp
|
|
154 |
^ startTimestamp
|
|
155 |
|
|
156 |
"Created: / 24-11-2007 / 09:01:12 / janfrog"
|
|
157 |
! !
|
|
158 |
|
|
159 |
!Profiler methodsFor:'profiling'!
|
|
160 |
|
|
161 |
spyOn: aBlock interval: interval
|
|
162 |
|
|
163 |
startTimestamp := Timestamp now.
|
|
164 |
super spyOn: aBlock interval: interval.
|
|
165 |
self nTally isZero ifFalse:[self tree computePercentage: self nTally].
|
|
166 |
^self
|
|
167 |
|
|
168 |
"Created: / 24-11-2007 / 08:21:28 / janfrog"
|
|
169 |
! !
|
|
170 |
|
|
171 |
!Profiler class methodsFor:'documentation'!
|
|
172 |
|
|
173 |
version_CVS
|
10060
|
174 |
^ '$Header: /cvs/stx/stx/libtool/Tools__Profiler.st,v 1.2 2011-07-03 17:46:43 cg Exp $'
|
9991
|
175 |
!
|
|
176 |
|
|
177 |
version_SVN
|
|
178 |
^ '§Id: Tools__Profiler.st 7486 2009-10-26 22:06:24Z vranyj1 §'
|
|
179 |
! !
|