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

Method snapshot_stats

tools/python-3.11.9-amd64/Lib/cProfile.py:55–88  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

53 self.snapshot_stats()
54
55 def snapshot_stats(self):
56 entries = self.getstats()
57 self.stats = {}
58 callersdicts = {}
59 # call information
60 for entry in entries:
61 func = label(entry.code)
62 nc = entry.callcount # ncalls column of pstats (before '/')
63 cc = nc - entry.reccallcount # ncalls column of pstats (after '/')
64 tt = entry.inlinetime # tottime column of pstats
65 ct = entry.totaltime # cumtime column of pstats
66 callers = {}
67 callersdicts[id(entry.code)] = callers
68 self.stats[func] = cc, nc, tt, ct, callers
69 # subcall information
70 for entry in entries:
71 if entry.calls:
72 func = label(entry.code)
73 for subentry in entry.calls:
74 try:
75 callers = callersdicts[id(subentry.code)]
76 except KeyError:
77 continue
78 nc = subentry.callcount
79 cc = nc - subentry.reccallcount
80 tt = subentry.inlinetime
81 ct = subentry.totaltime
82 if func in callers:
83 prev = callers[func]
84 nc += prev[0]
85 cc += prev[1]
86 tt += prev[2]
87 ct += prev[3]
88 callers[func] = nc, cc, tt, ct
89
90 # The following two methods can be called by clients to use
91 # a profiler to profile a statement, given as a string.

Callers 1

create_statsMethod · 0.95

Calls 2

labelFunction · 0.85
idFunction · 0.50

Tested by

no test coverage detected