Coverage for python/lsst/pipe/base/timer.py : 89%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1#
2# LSST Data Management System
3# Copyright 2008, 2009, 2010, 2011 LSST Corporation.
4#
5# This product includes software developed by the
6# LSST Project (http://www.lsst.org/).
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the LSST License Statement and
19# the GNU General Public License along with this program. If not,
20# see <http://www.lsstcorp.org/LegalNotices/>.
21#
22"""Utilities for measuring execution time.
23"""
24__all__ = ["logInfo", "timeMethod"]
26import logging
27from deprecated.sphinx import deprecated
28import lsst.utils.timer
31@deprecated(reason="logInfo has been replaced by lsst.utils.timer.logInfo."
32 " Will be removed after v25.",
33 version="v24", category=FutureWarning)
34def logInfo(obj, prefix, logLevel=logging.DEBUG, metadata=None, logger=None):
35 """Log timer information to ``obj.metadata`` and ``obj.log``.
37 Parameters
38 ----------
39 obj : `lsst.pipe.base.Task`-type or `None`
40 A `~lsst.pipe.base.Task` or any other object with these two attributes:
42 - ``metadata`` an instance of `lsst.daf.base.PropertyList`` (or other
43 object with ``add(name, value)`` method).
44 - ``log`` an instance of `logging.Logger` or subclass.
46 If `None`, at least one of ``metadata`` or ``logger`` should be passed
47 or this function will do nothing.
49 prefix
50 Name prefix, the resulting entries are ``CpuTime``, etc.. For example
51 timeMethod uses ``prefix = Start`` when the method begins and
52 ``prefix = End`` when the method ends.
53 logLevel : optional
54 Log level (an `logging` level constant, such as `logging.DEBUG`).
55 metadata : `lsst.daf.base.PropertyList`, optional
56 Metadata object to write entries to, overriding ``obj.metadata``.
57 logger : `logging.Logger`
58 Log object to write entries to, overriding ``obj.log``.
60 Notes
61 -----
62 Logged items include:
64 - ``Utc``: UTC date in ISO format (only in metadata since log entries have
65 timestamps).
66 - ``CpuTime``: System + User CPU time (seconds). This should only be used
67 in differential measurements; the time reference point is undefined.
68 - ``MaxRss``: maximum resident set size.
70 All logged resource information is only for the current process; child
71 processes are excluded.
72 """
73 return lsst.utils.timer.logInfo(obj, prefix, logLevel=logLevel, metadata=metadata, logger=logger)
76# Does this need a deprecation message?
77timeMethod = lsst.utils.timer.timeMethod