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

Method snapshot_stats

Lib/profiling/tracing/__init__.py:71–104  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

69 self.snapshot_stats()
70
71 def snapshot_stats(self):
72 entries = self.getstats()
73 self.stats = {}
74 callersdicts = {}
75 # call information
76 for entry in entries:
77 func = label(entry.code)
78 nc = entry.callcount # ncalls column of pstats (before '/')
79 cc = nc - entry.reccallcount # ncalls column of pstats (after '/')
80 tt = entry.inlinetime # tottime column of pstats
81 ct = entry.totaltime # cumtime column of pstats
82 callers = {}
83 callersdicts[id(entry.code)] = callers
84 self.stats[func] = cc, nc, tt, ct, callers
85 # subcall information
86 for entry in entries:
87 if entry.calls:
88 func = label(entry.code)
89 for subentry in entry.calls:
90 try:
91 callers = callersdicts[id(subentry.code)]
92 except KeyError:
93 continue
94 nc = subentry.callcount
95 cc = nc - subentry.reccallcount
96 tt = subentry.inlinetime
97 ct = subentry.totaltime
98 if func in callers:
99 prev = callers[func]
100 nc += prev[0]
101 cc += prev[1]
102 tt += prev[2]
103 ct += prev[3]
104 callers[func] = nc, cc, tt, ct
105
106 # The following two methods can be called by clients to use
107 # a profiler to profile a statement, given as a string.

Callers 1

create_statsMethod · 0.95

Calls 3

labelFunction · 0.85
idFunction · 0.85
getstatsMethod · 0.80

Tested by

no test coverage detected