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

Method profile_ctx

monai/utils/profiling.py:311–321  ·  view source on GitHub ↗

Creates a context to profile, placing a timing result onto the queue when it exits.

(self, name, caller=None)

Source from the content-addressed store, hash-verified

309
310 @contextmanager
311 def profile_ctx(self, name, caller=None):
312 """Creates a context to profile, placing a timing result onto the queue when it exits."""
313 if caller is None:
314 caller = getframeinfo(stack()[2][0]) # caller of context, not something in contextlib
315
316 start = perf_counter_ns()
317 try:
318 yield
319 finally:
320 diff = perf_counter_ns() - start
321 self._put_result(name, diff, caller.filename, caller.lineno)
322
323 def profile_callable(self, name=None):
324 """

Callers 3

_outerMethod · 0.95
startMethod · 0.80
test_profile_contextMethod · 0.80

Calls 2

_put_resultMethod · 0.95
stackFunction · 0.85

Tested by 1

test_profile_contextMethod · 0.64