kernprof module

Script to conveniently run profilers on code in a variety of circumstances.

kernprof.execfile(filename, globals=None, locals=None)[source]

Python 3.x doesn’t have ‘execfile’ builtin

kernprof.is_generator(f)[source]

Return True if a function is a generator.

class kernprof.ContextualProfile(*args, **kwds)[source]

Bases: Profile

A subclass of Profile that adds a context manager for Python 2.5 with: statements and a decorator.

enable_by_count(subcalls=True, builtins=True)[source]

Enable the profiler if it hasn’t been enabled before.

disable_by_count()[source]

Disable the profiler if the number of disable requests matches the number of enable requests.

wrap_generator(func)[source]

Wrap a generator to profile it.

wrap_function(func)[source]

Wrap a function to profile it.

class kernprof.RepeatedTimer(interval, dump_func, outfile)[source]

Bases: object

Background timer for outputting file every n seconds.

Adapted from https://stackoverflow.com/questions/474528/what-is-the-best-way-to-repeatedly-execute-a-function-every-x-seconds/40965385#40965385

_run()[source]
start()[source]
stop()[source]
kernprof.find_script(script_name)[source]

Find the script.

If the input is not a file, then $PATH will be searched.

kernprof.main(args=None)[source]