eric6/DebugClients/Python/PyProfile.py

changeset 8243
cc717c2ae956
parent 8240
93b8a353c4bf
equal deleted inserted replaced
8242:aa713ac50c0d 8243:cc717c2ae956
50 Private method to restore the timing data from the timing cache. 50 Private method to restore the timing data from the timing cache.
51 """ 51 """
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 with contextlib.suppress(OSError, EOFError, ValueError, TypeError), \
56 with open(self.timingCache, 'rb') as cache: 56 open(self.timingCache, 'rb') as cache:
57 timings = marshal.load(cache) # secok 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 (OSError, EOFError, ValueError, TypeError):
61 pass
62 60
63 def save(self): 61 def save(self):
64 """ 62 """
65 Public method to store the collected profile data. 63 Public method to store the collected profile data.
66 """ 64 """
77 Public method to dump the statistics data. 75 Public method to dump the statistics data.
78 76
79 @param file name of the file to write to (string) 77 @param file name of the file to write to (string)
80 """ 78 """
81 self.create_stats() 79 self.create_stats()
82 try: 80 with contextlib.suppress(OSError, pickle.PickleError), \
83 with open(file, 'wb') as f: 81 open(file, 'wb') as f:
84 pickle.dump(self.stats, f, 4) 82 pickle.dump(self.stats, f, 4)
85 except (OSError, pickle.PickleError):
86 pass
87 83
88 def erase(self): 84 def erase(self):
89 """ 85 """
90 Public method to erase the collected timing data. 86 Public method to erase the collected timing data.
91 """ 87 """

eric ide

mercurial