lsst.dax.apdb g5ea96fc03c+33ab2bc355
|
Public Member Functions | |
__init__ (self, str name, *MonAgent|logging.Logger args, _TagsType|None tags=None, int log_level=logging.INFO) | |
Timer | start (self) |
Timer | stop (self) |
Timer | dump (self) |
tuple[float, float, float] | accumulated (self) |
dict[str, float] | as_dict (self, str prefix="") |
str | __str__ (self) |
Timer | __enter__ (self) |
Any | __exit__ (self, type|None exc_type, Any exc_val, Any exc_tb) |
Protected Attributes | |
_name | |
_tags | |
_log_level | |
_startReal | |
_startUser | |
_startSys | |
_sumReal | |
_sumUser | |
_sumSys | |
Instance of this class can be used to track consumed time. Parameters ---------- name : `str` Timer name, will be use for reporting to both monitoring and logging. Typically the name should look like an identifier for ease of use with downstream monitoring software. *args : `MonAgent` or `logging.Logger` Positional arguments can include a combination of `MonAgent` and `logging.Logger` instances. They will be used to report accumulated times on exit from context or by calling `dump` method directly. tags : `~collections.abc.Mapping` [`str`, `str` or `int`], optional Keyword argument, additional tags added to monitoring report and logging output. log_level : `int`, optional Keyword argument, level used for logging output, default is `logging.INFO`. Notes ----- This class is also a context manager and can be used in a `with` statement. By default it prints consumed CPU time and real time spent in a context. Example: with Timer("SelectTimer", logger): engine.execute('SELECT ...')
Timer lsst.dax.apdb.timer.Timer.__enter__ | ( | self | ) |
Enter context, start timer
Any lsst.dax.apdb.timer.Timer.__exit__ | ( | self, | |
type | None | exc_type, | ||
Any | exc_val, | ||
Any | exc_tb ) |
Exit context, stop and dump timer
tuple[float, float, float] lsst.dax.apdb.timer.Timer.accumulated | ( | self | ) |
Return accumulated real, user, and system times in seconds.
dict[str, float] lsst.dax.apdb.timer.Timer.as_dict | ( | self, | |
str | prefix = "" ) |
Return accumulated real, user, and system times as dictionary.
Timer lsst.dax.apdb.timer.Timer.dump | ( | self | ) |
Dump timer statistics
Timer lsst.dax.apdb.timer.Timer.start | ( | self | ) |
Start timer.
Timer lsst.dax.apdb.timer.Timer.stop | ( | self | ) |
Stop timer.