lsst.pipe.base  20.0.0-27-g71224ee+38e0695d12
Classes | Functions
lsst.pipe.base.cmdLineTask Namespace Reference

Classes

class  ButlerInitializedTaskRunner
 
class  CmdLineTask
 
class  LegacyTaskRunner
 
class  TaskRunner
 

Functions

def profile (filename, log=None)
 

Function Documentation

◆ profile()

def lsst.pipe.base.cmdLineTask.profile (   filename,
  log = None 
)
Context manager for profiling with cProfile.


Parameters
----------
filename : `str`
    Filename to which to write profile (profiling disabled if `None` or
    empty).
log : `lsst.log.Log`, optional
    Log object for logging the profile operations.

If profiling is enabled, the context manager returns the cProfile.Profile
object (otherwise it returns None), which allows additional control over
profiling.  You can obtain this using the "as" clause, e.g.:

.. code-block:: python

    with profile(filename) as prof:
        runYourCodeHere()

The output cumulative profile can be printed with a command-line like:

.. code-block:: bash

    python -c 'import pstats; \
        pstats.Stats("<filename>").sort_stats("cumtime").print_stats(30)'

Definition at line 50 of file cmdLineTask.py.