MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / timeit

Method timeit

detrsmpl/utils/demo_utils.py:766–784  ·  view source on GitHub ↗

Timing a code snippet with an assigned name. Args: timer_name (str): The unique name of the interested code snippet to handle multiple timers and generate reports. Note that '_FPS_' is a special key that the measurement will be in `fps` instead

(self, timer_name='_FPS_')

Source from the content-addressed store, hash-verified

764
765 @contextmanager
766 def timeit(self, timer_name='_FPS_'):
767 """Timing a code snippet with an assigned name.
768
769 Args:
770 timer_name (str): The unique name of the interested code snippet to
771 handle multiple timers and generate reports. Note that '_FPS_'
772 is a special key that the measurement will be in `fps` instead
773 of `millisecond`. Also see `report` and `report_strings`.
774 Default: '_FPS_'.
775 Note:
776 This function should always be used in a `with` statement, as shown
777 in the example.
778 """
779 self._timer_stack.append((timer_name, Timer()))
780 try:
781 yield
782 finally:
783 timer_name, timer = self._timer_stack.pop()
784 self._record[timer_name].update(timer.since_start())
785
786 def report(self, key=None):
787 """Report timing information.

Callers

nothing calls this directly

Calls 1

updateMethod · 0.45

Tested by

no test coverage detected