class ProfilerMiddleware:
Wrap a WSGI application and profile the execution of each request. Responses are buffered so that timings are more exact.
If stream is given, pstats.Stats
are written to it
after each request. If profile_dir is given, cProfile
data files are saved to that directory, one file per request.
The filename can be customized by passing filename_format. If
it is a string, it will be formatted using str.format
with
the following fields available:
If it is a callable, it will be called with the WSGI environ dict and should return a filename.
from werkzeug.middleware.profiler import ProfilerMiddleware app = ProfilerMiddleware(app)
Parameters | |
app | The WSGI application to wrap. |
stream | Write stats to this stream. Disable with None. |
sort_by | A tuple of columns to sort stats by. See
pstats.Stats.sort_stats . |
restrictions | A tuple of restrictions to filter stats by. See
pstats.Stats.print_stats . |
profile_dir | Save profile data files to this directory. |
filename_format | Format string for profile data file names, or a callable returning a name. See explanation above. |
Method | __call__ |
Undocumented |
Method | __init__ |
Undocumented |
Instance Variable | _app |
Undocumented |
Instance Variable | _filename_format |
Undocumented |
Instance Variable | _profile_dir |
Undocumented |
Instance Variable | _restrictions |
Undocumented |
Instance Variable | _sort_by |
Undocumented |
Instance Variable | _stream |
Undocumented |
Undocumented
Parameters | |
environ:WSGIEnvironment | Undocumented |
start_response:StartResponse | Undocumented |
Returns | |
t.Iterable[ | Undocumented |
Undocumented
Parameters | |
app:WSGIApplication | Undocumented |
stream:t.IO[ | Undocumented |
sort_by:t.Iterable[ | Undocumented |
restrictions:t.Iterable[ | Undocumented |
profile_dir:t.Optional[ | Undocumented |
filename_format:str | Undocumented |