eric6/DebugClients/Python/PyProfile.py

changeset 8240
93b8a353c4bf
parent 8217
385f60c94548
child 8243
cc717c2ae956
equal deleted inserted replaced
8239:59a9a658618c 8240:93b8a353c4bf
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 # secok 13 import pickle # secok
14 import contextlib
14 15
15 16
16 class PyProfile(profile.Profile): 17 class PyProfile(profile.Profile):
17 """ 18 """
18 Class extending the standard Python profiler with additional methods. 19 Class extending the standard Python profiler with additional methods.
62 def save(self): 63 def save(self):
63 """ 64 """
64 Public method to store the collected profile data. 65 Public method to store the collected profile data.
65 """ 66 """
66 # dump the raw timing data 67 # dump the raw timing data
67 try: 68 with contextlib.suppress(OSError), \
68 with open(self.timingCache, 'wb') as cache: 69 open(self.timingCache, 'wb') as cache:
69 marshal.dump(self.timings, cache) 70 marshal.dump(self.timings, cache)
70 except OSError:
71 pass
72 71
73 # dump the profile data 72 # dump the profile data
74 self.dump_stats(self.profileCache) 73 self.dump_stats(self.profileCache)
75 74
76 def dump_stats(self, file): 75 def dump_stats(self, file):

eric ide

mercurial