profile.py

openmdao.util.profile.get_method_class(meth)[source]

Return the class that actually defined the given method.

openmdao.util.profile.process_profile(flist)[source]

Take the generated raw profile data, potentially from multiple files, and combine it to get hierarchy structure and total execution counts and timing data.

Args:

flist : list of str

Names of raw profiling data files.

openmdao.util.profile.prof_dump(fname=None, include_tstamp=True)[source]

Print the contents of the given raw profile data file to stdout.

Args:

fname : str

Name of raw profile data file.

include_tstamp : bool (True)

If True, include the timestamp in the dump.

openmdao.util.profile.prof_totals()[source]

Called from the command line to create a file containing total elapsed times and number of calls for all profiled functions.

openmdao.util.profile.prof_view()[source]

Called from a command line to generate an html viewer for profile data.

openmdao.util.profile.setup(top, prefix='prof_raw', methods=None, obj_iter=<function _obj_iter>, prof_dir=None)[source]

Instruments certain important openmdao methods for profiling.

Args:

top : object

The top object to be profiled. The top object must be an instance of a class that is compatible with the object iterator function. The default object iterator function expects the top object to be a Problem or a System.

prefix : str (‘prof_raw’)

Prefix used for the raw profile data. Process rank will be appended to it to get the actual filename. When not using MPI, rank=0.

methods : dict, optional

A dict of profiled methods to override the default set. The key is the method name and the value is a tuple of class objects used for isinstance checking. The default set of methods is:

{
    "setup": (Problem,),
    "run": (Problem,),
    "calc_gradient": (Problem,),
    "solve_nonlinear": (System,),
    "apply_nonlinear": (System,),
    "solve_linear": (System,),
    "apply_linear": (System,),
    "solve": (SolverBase,),
    "fd_jacobian": (System,),
    "linearize": (System,),
    "complex_step_jacobian": (Component,),
    "record_iteration": (RecordingManager,),
    "record_derivatives": (RecordingManager,),
    "_transfer_data": (Group,),
}

obj_iter : function, optional

An iterator that provides objects to be checked for matching profile methods. The default object iterator iterates over a Problem or System.

prof_dir : str

Directory where the profile files will be written.

openmdao.util.profile.start()[source]

Turn on profiling.

openmdao.util.profile.stop()[source]

Turn off profiling.

openmdao.util.profile.wrap_methods(obj_iter, methods, dec_factory)[source]

Iterate over a collection of objects and wrap any of their methods that match the given set of method names with a decorator created using the given dectorator factory.