Defines a new inner trace function just for this call.
(frame, why, arg)
| 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 |
nothing calls this directly
no test coverage detected