paste.debug.profile – profile applications and requests

Middleware that profiles the request and displays profiling information at the bottom of each page.

Module Contents

class paste.debug.profile.ProfileMiddleware(app, global_conf=None, log_filename='profile.log.tmp', limit=40)

Middleware that profiles all requests.

All HTML pages will have profiling information appended to them. The data is isolated to that single request, and does not include data from previous requests.

This uses the hotshot module, which affects performance of the application. It also runs in a single-threaded mode, so it is only usable in development environments.

paste.debug.profile.make_profile_middleware(app, global_conf, log_filename='profile.log.tmp', limit=40)

Wrap the application in a component that will profile each request. The profiling data is then appended to the output of each page.

Note that this serializes all requests (i.e., removing concurrency). Therefore never use this in production.

paste.debug.profile.profile_decorator(**options)

Profile a single function call.

Used around a function, like:

@profile_decorator(options...)
def ...

All calls to the function will be profiled. The options are all keywords, and are:

log_file:
The filename to log to (or 'stdout' or 'stderr'). Default: stderr.
display_limit:
Only show the top N items, default: 20.
sort_stats:
A list of string-attributes to sort on. Default ('time', 'calls').
strip_dirs:
Strip directories/module names from files? Default True.
add_info:
If given, this info will be added to the report (for your own tracking). Default: none.
log_filename:
The temporary filename to log profiling data to. Default; ./profile_data.log.tmp
no_profile:
If true, then don’t actually profile anything. Useful for conditional profiling.