MCPcopy
hub / github.com/nvdv/vprof / profile_function

Method profile_function

vprof/profiler.py:84–100  ·  view source on GitHub ↗

Runs cProfile on a function.

(self)

Source from the content-addressed store, hash-verified

82 return base_profiler.run_in_separate_process(self._profile_module)
83
84 def profile_function(self):
85 """Runs cProfile on a function."""
86 prof = cProfile.Profile()
87 prof.enable()
88 result = self._run_object(*self._run_args, **self._run_kwargs)
89 prof.disable()
90 prof_stats = pstats.Stats(prof)
91 prof_stats.calc_callees()
92 return {
93 'objectName': self._object_name,
94 'callStats': self._transform_stats(prof_stats),
95 'totalTime': prof_stats.total_tt,
96 'primitiveCalls': prof_stats.prim_calls,
97 'totalCalls': prof_stats.total_calls,
98 'result': result,
99 'timestamp': int(time.time())
100 }

Callers 1

testRunAsFunctionMethod · 0.45

Calls 1

_transform_statsMethod · 0.95

Tested by 1

testRunAsFunctionMethod · 0.36