You copied the Doc URL to your clipboard.

Profiling individual functions in a Python module

You can add calls to gator.py profiling functions in your own code.

You can profile specific functions by creating a GatorProfiler object and calling the gator_profiler.runctx() or gator_profiler.call() functions as appropriate:

import gator				
    g = gator.GatorProfiler()
    g.runctx(some_function, args=(arg1, arg2, arg3), kwargs={'kwarg1':kwarg1})

Function some_function() is then called and profiled.

When you are tracing individual functions, gator.py runs in the following modes:

Profiling mode
Uses the Python sys.setprofile() function. It provides lower overhead analysis of a python script at the expense of only tracing function calls rather than individual lines of code. When this mode is enabled, you can see which functions were called and how often. The execution of lines within a function, or how often they were executed, cannot be viewed.
Trace mode
Uses the Python sys.settrace() function. It provides much more detailed analysis at the expense of a significantly larger profiling overhead. In this mode, individual lines are profiled.

In both modes, a full call-stack is collected.

The GatorProfiler constructor is defined as:

def __init__(self, trace_mode=False, debug_enabled=False, ignored_paths=[])

The arguments are:

trace_modeWhen FALSE, profiling mode is used. When TRUE, trace mode is used.
debug_enabledWhen TRUE, debug messages are output to stderr.
ignored_pathsA list of absolute paths (as strings) to any scripts that gator.py must not profile.

Note

You must start the Arm Streamline capture session before running your Python module.