Public Member Functions | |
| __init__ (self, str name, *MonAgent|logging.Logger args, _TagsType|None tags=None, int log_level=logging.INFO) | |
| None | add_values (self, **int|float values) |
| Timer | start (self) |
| Timer | stop (self) |
| Timer | dump (self) |
| tuple[float, float, float] | accumulated (self) |
| dict[str, int|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) |
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.
| None lsst.dax.apdb.timer.Timer.add_values | ( | self, | |
| **int | float | values ) |
Add values to dump together with timing information.
Parameters
----------
**values : int | float
Key/values to add to timer information.
| dict[str, int | float] lsst.dax.apdb.timer.Timer.as_dict | ( | self, | |
| str | prefix = "" ) |
Return timers and extra values 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.