MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / sort_stats

Method sort_stats

tools/python-3.11.9-amd64/Lib/pstats.py:237–274  ·  view source on GitHub ↗
(self, *field)

Source from the content-addressed store, hash-verified

235 return self.sort_arg_dict
236
237 def sort_stats(self, *field):
238 if not field:
239 self.fcn_list = 0
240 return self
241 if len(field) == 1 and isinstance(field[0], int):
242 # Be compatible with old profiler
243 field = [ {-1: "stdname",
244 0: "calls",
245 1: "time",
246 2: "cumulative"}[field[0]] ]
247 elif len(field) >= 2:
248 for arg in field[1:]:
249 if type(arg) != type(field[0]):
250 raise TypeError("Can't have mixed argument type")
251
252 sort_arg_defs = self.get_sort_arg_defs()
253
254 sort_tuple = ()
255 self.sort_type = ""
256 connector = ""
257 for word in field:
258 if isinstance(word, SortKey):
259 word = word.value
260 sort_tuple = sort_tuple + sort_arg_defs[word][0]
261 self.sort_type += connector + sort_arg_defs[word][1]
262 connector = ", "
263
264 stats_list = []
265 for func, (cc, nc, tt, ct, callers) in self.stats.items():
266 stats_list.append((cc, nc, tt, ct) + func +
267 (func_std_string(func), func))
268
269 stats_list.sort(key=cmp_to_key(TupleComp(sort_tuple).compare))
270
271 self.fcn_list = fcn_list = []
272 for tuple in stats_list:
273 fcn_list.append(tuple[-1])
274 return self
275
276 def reverse_order(self):
277 if self.fcn_list:

Callers 4

print_statsMethod · 0.80
do_sortMethod · 0.80
print_statsMethod · 0.80
ndiff.pyFile · 0.80

Calls 8

get_sort_arg_defsMethod · 0.95
cmp_to_keyFunction · 0.90
func_std_stringFunction · 0.85
TupleCompClass · 0.85
typeClass · 0.50
itemsMethod · 0.45
appendMethod · 0.45
sortMethod · 0.45

Tested by

no test coverage detected