lsst.pipe.base  13.0-12-gaf0c0ec+8
Functions
lsst.pipe.base.timer Namespace Reference

Functions

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

Function Documentation

◆ logInfo()

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.

◆ logPairs()

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.

◆ timeMethod()

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:

import lsst.pipe.base as pipeBase
class FooTask(pipeBase.Task):
...
@pipeBase.timeMethod
def run(self, ...): # or any other instance method you want to time
...
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.