Start timing the specific function. Note: If use_stack is True, only one timer can be active at a time. Once you stop this timer, the previous one will start again.
(fn_name, use_stack=True)
| 52 | |
| 53 | |
| 54 | def start(fn_name, use_stack=True): |
| 55 | """ |
| 56 | Start timing the specific function. |
| 57 | Note: If use_stack is True, only one timer can be active at a time. |
| 58 | Once you stop this timer, the previous one will start again. |
| 59 | """ |
| 60 | global _running_timer, _disable_all |
| 61 | |
| 62 | if _disable_all: |
| 63 | return |
| 64 | |
| 65 | if use_stack: |
| 66 | if _running_timer is not None: |
| 67 | stop(_running_timer, use_stack=False) |
| 68 | _timer_stack.append(_running_timer) |
| 69 | start(fn_name, use_stack=False) |
| 70 | _running_timer = fn_name |
| 71 | else: |
| 72 | _start_times[fn_name] = 0 |
| 73 | starter.record() |
| 74 | |
| 75 | |
| 76 | def stop(fn_name=None, use_stack=True): |