eric6/DebugClients/Python/PyProfile.py

changeset 7628
f904d0eef264
parent 7360
9190402e4505
child 7637
c878e8255972
equal deleted inserted replaced
7626:7f643d41464e 7628:f904d0eef264
8 8
9 import os 9 import os
10 import marshal 10 import marshal
11 import profile 11 import profile
12 import atexit 12 import atexit
13 import pickle 13 import pickle # secok
14 import sys 14 import sys
15 15
16 16
17 class PyProfile(profile.Profile): 17 class PyProfile(profile.Profile):
18 """ 18 """
52 if not os.path.exists(self.timingCache): 52 if not os.path.exists(self.timingCache):
53 return 53 return
54 54
55 try: 55 try:
56 cache = open(self.timingCache, 'rb') 56 cache = open(self.timingCache, 'rb')
57 timings = marshal.load(cache) 57 timings = marshal.load(cache) # secok
58 if isinstance(timings, dict): 58 if isinstance(timings, dict):
59 self.timings = timings 59 self.timings = timings
60 except Exception: 60 except Exception: # secok
61 pass 61 pass
62 finally: 62 finally:
63 cache.close() 63 cache.close()
64 64
65 def save(self): 65 def save(self):
68 """ 68 """
69 # dump the raw timing data 69 # dump the raw timing data
70 try: 70 try:
71 cache = open(self.timingCache, 'wb') 71 cache = open(self.timingCache, 'wb')
72 marshal.dump(self.timings, cache) 72 marshal.dump(self.timings, cache)
73 except Exception: 73 except Exception: # secok
74 pass 74 pass
75 finally: 75 finally:
76 cache.close() 76 cache.close()
77 77
78 # dump the profile data 78 # dump the profile data
152 """ 152 """
153 if self.cur and frame.f_back is not self.cur[-2]: 153 if self.cur and frame.f_back is not self.cur[-2]:
154 rpt, rit, ret, rfn, rframe, rcur = self.cur 154 rpt, rit, ret, rfn, rframe, rcur = self.cur
155 if not isinstance(rframe, profile.Profile.fake_frame): 155 if not isinstance(rframe, profile.Profile.fake_frame):
156 assert rframe.f_back is frame.f_back, ("Bad call", rfn, 156 assert rframe.f_back is frame.f_back, ("Bad call", rfn,
157 # secok
157 rframe, rframe.f_back, 158 rframe, rframe.f_back,
158 frame, frame.f_back) 159 frame, frame.f_back)
159 self.trace_dispatch_return(rframe, 0) 160 self.trace_dispatch_return(rframe, 0)
160 assert (self.cur is None or 161 assert (self.cur is None or # secok
161 frame.f_back is self.cur[-2]), ("Bad call", 162 frame.f_back is self.cur[-2]), ("Bad call",
162 self.cur[-3]) 163 self.cur[-3])
163 fcode = frame.f_code 164 fcode = frame.f_code
164 fn = (self.fix_frame_filename(frame), 165 fn = (self.fix_frame_filename(frame),
165 fcode.co_firstlineno, fcode.co_name) 166 fcode.co_firstlineno, fcode.co_name)

eric ide

mercurial