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

Method create_stats

Lib/profiling/sampling/pstats_collector.py:72–86  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

70
71 # Needed for compatibility with pstats.Stats
72 def create_stats(self):
73 sample_interval_sec = self.sample_interval_usec / MICROSECONDS_PER_SECOND
74 callers = {}
75 for fname, call_counts in self.result.items():
76 total = call_counts["direct_calls"] * sample_interval_sec
77 cumulative_calls = call_counts["cumulative_calls"]
78 cumulative = cumulative_calls * sample_interval_sec
79 callers = dict(self.callers.get(fname, {}))
80 self.stats[fname] = (
81 call_counts["direct_calls"], # cc = direct calls for sample percentage
82 cumulative_calls, # nc = cumulative calls for cumulative percentage
83 total,
84 cumulative,
85 callers,
86 )
87
88 def print_stats(self, sort=-1, limit=None, show_summary=True, mode=None):
89 """Print formatted statistics to stdout."""

Calls 2

itemsMethod · 0.45
getMethod · 0.45