lsst.pipe.base  13.0-12-gaf0c0ec+9
 All Classes Namespaces Files Functions Variables Pages
Functions | Variables
lsst.pipe.base.timer Namespace Reference

Functions

def logPairs
 Log (name, value) pairs to obj.metadata and obj.log. More...
 
def logInfo
 Log timer information to obj.metadata and obj.log. More...
 
def timeMethod
 Decorator to measure duration of a task method. More...
 

Variables

list __all__ = ["logInfo", "timeMethod"]
 

Function Documentation

def lsst.pipe.base.timer.logInfo (   obj,
  prefix,
  logLevel = Log.DEBUG 
)

Log timer information to obj.metadata and obj.log.

Parameters
obja Task, or any other object with these two attributes:
  • metadata an instance of lsst.daf.base.PropertyList (or other object with add(name, value) method)
  • log an instance of lsst.log.Log
prefixname prefix, the resulting entries are <prefix>CpuTime, etc. For example timeMethod uses prefix = <methodName>Start when the method begins and prefix = <methodName>End when the method ends.
logLevellog level (an lsst.log level, constant such as lsst.log.Log.DEBUG)

Logged items include:

  • Utc: UTC date in ISO format (only in metadata since log entries have timestamps)
  • CpuTime: CPU time (seconds)
  • MaxRss: maximum resident set size All logged resource information is only for the current process; child processes are excluded

Definition at line 55 of file timer.py.

def lsst.pipe.base.timer.logPairs (   obj,
  pairs,
  logLevel = Log.DEBUG 
)

Log (name, value) pairs to obj.metadata and obj.log.

Parameters
obja Task, or any other object with these two attributes:
  • metadata an instance of lsst.daf.base.PropertyList (or other object with add(name, value) method)
  • log an instance of lsst.log.Log
pairsa collection of (name, value) pairs
logLevellog level (an lsst.log level constant, such as lsst.log.Log.DEBUG)

Definition at line 35 of file timer.py.

def lsst.pipe.base.timer.timeMethod (   func)

Decorator to measure duration of a task method.

Writes various measures of time and possibly memory usage to the task's metadata; all items are prefixed with the function name.

To use:

1 import lsst.pipe.base as pipeBase
2 class FooTask(pipeBase.Task):
3  ...
4 
5  @pipeBase.timeMethod
6  def run(self, ...): # or any other instance method you want to time
7  ...
Parameters
functhe method to wrap
Warning
This decorator only works with instance methods of Task, or any class with these attributes:
  • metadata: an instance of lsst.daf.base.PropertyList (or other object with add(name, value) method)
  • log: an instance of lsst.log.Log

Definition at line 94 of file timer.py.

Variable Documentation

list lsst.pipe.base.timer.__all__ = ["logInfo", "timeMethod"]

Definition at line 32 of file timer.py.