This module provides a simple WSGI profiler middleware for finding bottlenecks in web application. It uses the profile or cProfile module to do the profiling and writes the stats to the stream provided (defaults to stderr).
Example usage:
from werkzeug.contrib.profiler import ProfilerMiddleware
app = ProfilerMiddleware(app)
An object that redirects write calls to multiple streams. Use this to log to both sys.stdout and a file:
f = open('profiler.log', 'w')
stream = MergeStream(sys.stdout, f)
profiler = ProfilerMiddleware(app, stream)
Simple profiler middleware. Wraps a WSGI application and profiles a request. This intentionally buffers the response so that timings are more exact.
By giving the profile_dir argument, pstat.Stats files are saved to that directory, one file per request. Without it, a summary is printed to stream instead.
For the exact meaning of sort_by and restrictions consult the profile documentation.
New in version 0.9: Added support for restrictions and profile_dir.
Parameters: |
|
---|
Return a new callback for werkzeug.script that starts a local server with the profiler enabled.
from werkzeug.contrib import profiler
action_profile = profiler.make_action(make_app)