52 if not os.path.exists(self.timingCache): |
51 if not os.path.exists(self.timingCache): |
53 return |
52 return |
54 |
53 |
55 try: |
54 try: |
56 cache = open(self.timingCache, 'rb') |
55 cache = open(self.timingCache, 'rb') |
57 timings = marshal.load(cache) |
56 timings = marshal.load(cache) # secok |
58 if isinstance(timings, dict): |
57 if isinstance(timings, dict): |
59 self.timings = timings |
58 self.timings = timings |
60 except Exception: |
59 except (EnvironmentError, EOFError, ValueError, TypeError): |
61 pass |
60 pass |
62 finally: |
61 finally: |
63 cache.close() |
62 cache.close() |
64 |
63 |
65 def save(self): |
64 def save(self): |
68 """ |
67 """ |
69 # dump the raw timing data |
68 # dump the raw timing data |
70 try: |
69 try: |
71 cache = open(self.timingCache, 'wb') |
70 cache = open(self.timingCache, 'wb') |
72 marshal.dump(self.timings, cache) |
71 marshal.dump(self.timings, cache) |
73 except Exception: |
72 except EnvironmentError: |
74 pass |
73 pass |
75 finally: |
74 finally: |
76 cache.close() |
75 cache.close() |
77 |
76 |
78 # dump the profile data |
77 # dump the profile data |
117 code over a network... This logic deals with that. |
116 code over a network... This logic deals with that. |
118 |
117 |
119 @param frame the frame object |
118 @param frame the frame object |
120 @return fixed up file name (string) |
119 @return fixed up file name (string) |
121 """ |
120 """ |
122 if sys.version_info[0] == 2: |
121 versionExt = '.py3' |
123 versionExt = '.py2' |
|
124 else: |
|
125 versionExt = '.py3' |
|
126 |
122 |
127 # get module name from __file__ |
123 # get module name from __file__ |
128 if (not isinstance(frame, profile.Profile.fake_frame) and |
124 if (not isinstance(frame, profile.Profile.fake_frame) and |
129 '__file__' in frame.f_globals): |
125 '__file__' in frame.f_globals): |
130 root, ext = os.path.splitext(frame.f_globals['__file__']) |
126 root, ext = os.path.splitext(frame.f_globals['__file__']) |
152 """ |
148 """ |
153 if self.cur and frame.f_back is not self.cur[-2]: |
149 if self.cur and frame.f_back is not self.cur[-2]: |
154 rpt, rit, ret, rfn, rframe, rcur = self.cur |
150 rpt, rit, ret, rfn, rframe, rcur = self.cur |
155 if not isinstance(rframe, profile.Profile.fake_frame): |
151 if not isinstance(rframe, profile.Profile.fake_frame): |
156 assert rframe.f_back is frame.f_back, ("Bad call", rfn, |
152 assert rframe.f_back is frame.f_back, ("Bad call", rfn, |
|
153 # secok |
157 rframe, rframe.f_back, |
154 rframe, rframe.f_back, |
158 frame, frame.f_back) |
155 frame, frame.f_back) |
159 self.trace_dispatch_return(rframe, 0) |
156 self.trace_dispatch_return(rframe, 0) |
160 assert (self.cur is None or |
157 assert (self.cur is None or # secok |
161 frame.f_back is self.cur[-2]), ("Bad call", |
158 frame.f_back is self.cur[-2]), ("Bad call", |
162 self.cur[-3]) |
159 self.cur[-3]) |
163 fcode = frame.f_code |
160 fcode = frame.f_code |
164 fn = (self.fix_frame_filename(frame), |
161 fn = (self.fix_frame_filename(frame), |
165 fcode.co_firstlineno, fcode.co_name) |
162 fcode.co_firstlineno, fcode.co_name) |
179 "c_call": profile.Profile.trace_dispatch_c_call, |
176 "c_call": profile.Profile.trace_dispatch_c_call, |
180 "c_exception": profile.Profile.trace_dispatch_return, |
177 "c_exception": profile.Profile.trace_dispatch_return, |
181 # the C function returned |
178 # the C function returned |
182 "c_return": profile.Profile.trace_dispatch_return, |
179 "c_return": profile.Profile.trace_dispatch_return, |
183 } |
180 } |
184 |
|
185 # |
|
186 # eflag: noqa = M702 |
|