|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.DebugClients.Python.PyProfile</title> |
|
4 <meta charset="UTF-8"> |
|
5 <style> |
|
6 body { |
|
7 background: #EDECE6; |
|
8 margin: 0em 1em 10em 1em; |
|
9 color: black; |
|
10 } |
|
11 |
|
12 h1 { color: white; background: #85774A; } |
|
13 h2 { color: white; background: #85774A; } |
|
14 h3 { color: white; background: #9D936E; } |
|
15 h4 { color: white; background: #9D936E; } |
|
16 |
|
17 a { color: #BA6D36; } |
|
18 |
|
19 </style> |
|
20 </head> |
|
21 <body> |
|
22 <a NAME="top" ID="top"></a> |
|
23 <h1>eric7.DebugClients.Python.PyProfile</h1> |
|
24 |
|
25 <p> |
|
26 Module defining additions to the standard Python profile.py. |
|
27 </p> |
|
28 <h3>Global Attributes</h3> |
|
29 |
|
30 <table> |
|
31 <tr><td>None</td></tr> |
|
32 </table> |
|
33 <h3>Classes</h3> |
|
34 |
|
35 <table> |
|
36 |
|
37 <tr> |
|
38 <td><a href="#PyProfile">PyProfile</a></td> |
|
39 <td>Class extending the standard Python profiler with additional methods.</td> |
|
40 </tr> |
|
41 </table> |
|
42 <h3>Functions</h3> |
|
43 |
|
44 <table> |
|
45 <tr><td>None</td></tr> |
|
46 </table> |
|
47 <hr /> |
|
48 <hr /> |
|
49 <a NAME="PyProfile" ID="PyProfile"></a> |
|
50 <h2>PyProfile</h2> |
|
51 |
|
52 <p> |
|
53 Class extending the standard Python profiler with additional methods. |
|
54 </p> |
|
55 <p> |
|
56 This class extends the standard Python profiler by the functionality to |
|
57 save the collected timing data in a timing cache, to restore these data |
|
58 on subsequent calls, to store a profile dump to a standard filename and |
|
59 to erase these caches. |
|
60 </p> |
|
61 <h3>Derived from</h3> |
|
62 profile.Profile |
|
63 <h3>Class Attributes</h3> |
|
64 |
|
65 <table> |
|
66 <tr><td>dispatch</td></tr> |
|
67 </table> |
|
68 <h3>Class Methods</h3> |
|
69 |
|
70 <table> |
|
71 <tr><td>None</td></tr> |
|
72 </table> |
|
73 <h3>Methods</h3> |
|
74 |
|
75 <table> |
|
76 |
|
77 <tr> |
|
78 <td><a href="#PyProfile.__init__">PyProfile</a></td> |
|
79 <td>Constructor</td> |
|
80 </tr> |
|
81 <tr> |
|
82 <td><a href="#PyProfile.__restore">__restore</a></td> |
|
83 <td>Private method to restore the timing data from the timing cache.</td> |
|
84 </tr> |
|
85 <tr> |
|
86 <td><a href="#PyProfile.dump_stats">dump_stats</a></td> |
|
87 <td>Public method to dump the statistics data.</td> |
|
88 </tr> |
|
89 <tr> |
|
90 <td><a href="#PyProfile.erase">erase</a></td> |
|
91 <td>Public method to erase the collected timing data.</td> |
|
92 </tr> |
|
93 <tr> |
|
94 <td><a href="#PyProfile.fix_frame_filename">fix_frame_filename</a></td> |
|
95 <td>Public method used to fixup the filename for a given frame.</td> |
|
96 </tr> |
|
97 <tr> |
|
98 <td><a href="#PyProfile.save">save</a></td> |
|
99 <td>Public method to store the collected profile data.</td> |
|
100 </tr> |
|
101 <tr> |
|
102 <td><a href="#PyProfile.trace_dispatch_call">trace_dispatch_call</a></td> |
|
103 <td>Public method used to trace functions calls.</td> |
|
104 </tr> |
|
105 </table> |
|
106 <h3>Static Methods</h3> |
|
107 |
|
108 <table> |
|
109 <tr><td>None</td></tr> |
|
110 </table> |
|
111 |
|
112 <a NAME="PyProfile.__init__" ID="PyProfile.__init__"></a> |
|
113 <h4>PyProfile (Constructor)</h4> |
|
114 <b>PyProfile</b>(<i>basename, timer=None, bias=None</i>) |
|
115 |
|
116 <p> |
|
117 Constructor |
|
118 </p> |
|
119 <dl> |
|
120 |
|
121 <dt><i>basename</i></dt> |
|
122 <dd> |
|
123 name of the script to be profiled (string) |
|
124 </dd> |
|
125 <dt><i>timer</i></dt> |
|
126 <dd> |
|
127 function defining the timing calculation |
|
128 </dd> |
|
129 <dt><i>bias</i></dt> |
|
130 <dd> |
|
131 calibration value (float) |
|
132 </dd> |
|
133 </dl> |
|
134 <a NAME="PyProfile.__restore" ID="PyProfile.__restore"></a> |
|
135 <h4>PyProfile.__restore</h4> |
|
136 <b>__restore</b>(<i></i>) |
|
137 |
|
138 <p> |
|
139 Private method to restore the timing data from the timing cache. |
|
140 </p> |
|
141 <a NAME="PyProfile.dump_stats" ID="PyProfile.dump_stats"></a> |
|
142 <h4>PyProfile.dump_stats</h4> |
|
143 <b>dump_stats</b>(<i>file</i>) |
|
144 |
|
145 <p> |
|
146 Public method to dump the statistics data. |
|
147 </p> |
|
148 <dl> |
|
149 |
|
150 <dt><i>file</i></dt> |
|
151 <dd> |
|
152 name of the file to write to (string) |
|
153 </dd> |
|
154 </dl> |
|
155 <a NAME="PyProfile.erase" ID="PyProfile.erase"></a> |
|
156 <h4>PyProfile.erase</h4> |
|
157 <b>erase</b>(<i></i>) |
|
158 |
|
159 <p> |
|
160 Public method to erase the collected timing data. |
|
161 </p> |
|
162 <a NAME="PyProfile.fix_frame_filename" ID="PyProfile.fix_frame_filename"></a> |
|
163 <h4>PyProfile.fix_frame_filename</h4> |
|
164 <b>fix_frame_filename</b>(<i>frame</i>) |
|
165 |
|
166 <p> |
|
167 Public method used to fixup the filename for a given frame. |
|
168 </p> |
|
169 <p> |
|
170 The logic employed here is that if a module was loaded |
|
171 from a .pyc file, then the correct .py to operate with |
|
172 should be in the same path as the .pyc. The reason this |
|
173 logic is needed is that when a .pyc file is generated, the |
|
174 filename embedded and thus what is readable in the code object |
|
175 of the frame object is the fully qualified filepath when the |
|
176 pyc is generated. If files are moved from machine to machine |
|
177 this can break debugging as the .pyc will refer to the .py |
|
178 on the original machine. Another case might be sharing |
|
179 code over a network... This logic deals with that. |
|
180 </p> |
|
181 <dl> |
|
182 |
|
183 <dt><i>frame</i></dt> |
|
184 <dd> |
|
185 the frame object |
|
186 </dd> |
|
187 </dl> |
|
188 <dl> |
|
189 <dt>Return:</dt> |
|
190 <dd> |
|
191 fixed up file name (string) |
|
192 </dd> |
|
193 </dl> |
|
194 <a NAME="PyProfile.save" ID="PyProfile.save"></a> |
|
195 <h4>PyProfile.save</h4> |
|
196 <b>save</b>(<i></i>) |
|
197 |
|
198 <p> |
|
199 Public method to store the collected profile data. |
|
200 </p> |
|
201 <a NAME="PyProfile.trace_dispatch_call" ID="PyProfile.trace_dispatch_call"></a> |
|
202 <h4>PyProfile.trace_dispatch_call</h4> |
|
203 <b>trace_dispatch_call</b>(<i>frame, t</i>) |
|
204 |
|
205 <p> |
|
206 Public method used to trace functions calls. |
|
207 </p> |
|
208 <p> |
|
209 This is a variant of the one found in the standard Python |
|
210 profile.py calling fix_frame_filename above. |
|
211 </p> |
|
212 <dl> |
|
213 |
|
214 <dt><i>frame</i></dt> |
|
215 <dd> |
|
216 reference to the call frame |
|
217 </dd> |
|
218 <dt><i>t</i></dt> |
|
219 <dd> |
|
220 arguments |
|
221 </dd> |
|
222 </dl> |
|
223 <dl> |
|
224 <dt>Return:</dt> |
|
225 <dd> |
|
226 flag indicating a successful handling (boolean) |
|
227 </dd> |
|
228 </dl> |
|
229 <div align="right"><a href="#top">Up</a></div> |
|
230 <hr /> |
|
231 </body></html> |