MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / _call_profiler

Method _call_profiler

monai/utils/profiling.py:250–260  ·  view source on GitHub ↗

Defines a new inner trace function just for this call.

(frame, why, arg)

Source from the content-addressed store, hash-verified

248 start = perf_counter_ns()
249
250 def _call_profiler(frame, why, arg):
251 """Defines a new inner trace function just for this call."""
252 if why == "return":
253 diff = perf_counter_ns() - start
254 f_code = calling_frame.f_code
255 self_obj = calling_frame.f_locals.get("self", None)
256 name = f_code.co_name
257 if self_obj is not None:
258 name = f"{type(self_obj).__name__}.{name}"
259
260 self._put_result(name, diff, f_code.co_filename, f_code.co_firstlineno)
261
262 # This function will be used to trace this specific call now, however any new functions calls
263 # within will cause a "call" frame to be sent to `_trace_call` rather than to it, ie. it's not

Callers

nothing calls this directly

Calls 2

_put_resultMethod · 0.95
getMethod · 0.80

Tested by

no test coverage detected