time_this

lsst.utils.timer.time_this(log: Optional[LsstLoggers] = None, msg: Optional[str] = None, level: int = 10, prefix: Optional[str] = 'timer', args: Iterable[Any] = (), mem_usage: bool = False, mem_child: bool = False, mem_unit: u.Quantity = Unit('byte'), mem_fmt: str = '.0f') Iterator[None]

Time the enclosed block and issue a log message.

Parameters:
loglogging.Logger, optional

Logger to use to report the timer message. The root logger will be used if none is given.

msgstr, optional

Context to include in log message.

levelint, optional

Python logging level to use to issue the log message. If the code block raises an exception the log message will automatically switch to level ERROR.

prefixstr, optional

Prefix to use to prepend to the supplied logger to create a new logger to use instead. No prefix is used if the value is set to None. Defaults to “timer”.

argsiterable of any

Additional parameters passed to the log command that should be written to msg.

mem_usagebool, optional

Flag indicating whether to include the memory usage in the report. Defaults, to False.

mem_childbool, optional

Flag indication whether to include memory usage of the child processes.

mem_unitastropy.units.Unit, optional

Unit to use when reporting the memory usage. Defaults to bytes.

mem_fmtstr, optional

Format specifier to use when displaying values related to memory usage. Defaults to ‘.0f’.