tlc.core.utils.scoped_timer
#
Module Contents#
Classes#
Class |
Description |
---|---|
A context manager for profiling code execution time. |
API#
- class tlc.core.utils.scoped_timer.ScopedTimer(label: str = '', indentation: int = 0, enter_msg: bool = False)#
A context manager for profiling code execution time.
This class measures the execution time of a block of code or function. Can be used as a decorator or with a
with
statement.- Example:
with ScopedTimer("Some Code"): ... # some time-consuming code here @ScopedTimer("Some Function") def time_consuming_function(): ... # some time-consuming code here
- Parameters:
reason – A description of the code block or function being timed.
indentation – The number of spaces for indentation in the printed log. Default is 0.
enter_msg – A flag to specify whether to print a message at the start and end of the timer.