MCPcopy Index your code
hub / github.com/python/cpython / load_stats

Method load_stats

Lib/pstats.py:136–161  ·  view source on GitHub ↗
(self, arg)

Source from the content-addressed store, hash-verified

134 raise
135
136 def load_stats(self, arg):
137 if arg is None:
138 self.stats = {}
139 return
140 elif isinstance(arg, str):
141 with open(arg, 'rb') as f:
142 stats = marshal.load(f)
143 if (('__sampled__',)) in stats:
144 stats.pop((('__sampled__',)))
145 self.__class__ = SampledStats
146 self.stats = stats
147 try:
148 file_stats = os.stat(arg)
149 arg = time.ctime(file_stats.st_mtime) + " " + arg
150 except: # in case this is not unix
151 pass
152 self.files = [arg]
153 elif hasattr(arg, 'create_stats'):
154 arg.create_stats()
155 self.stats = arg.stats
156 arg.stats = {}
157 return
158 if not self.stats:
159 raise TypeError("Cannot create or construct a %r object from %r"
160 % (self.__class__, arg))
161 return
162
163 def get_top_level_stats(self):
164 for func, (cc, nc, tt, ct, callers) in self.stats.items():

Callers 3

initMethod · 0.95

Calls 6

openFunction · 0.70
loadMethod · 0.45
popMethod · 0.45
statMethod · 0.45
ctimeMethod · 0.45
create_statsMethod · 0.45

Tested by 2