ProfileMiddleware

Qualified name: intranet.middleware.profiler.ProfileMiddleware

class intranet.middleware.profiler.ProfileMiddleware[source]

Bases: object

Displays timing or profiling for any view. http://yoursite.com/yourview/?time or http://yoursite.com/yourview/?prof

Record the time taken by Django and the project code to generate the web page and by the database to make the queries. Accumulate repeated web page visits and display the accumulated statistics in the web browser in place of the normal web page. The availability of this middleware is controlled by the DEBUG flas in settings.py. To time a page, add ‘?time’ (or ‘&time’). To clear out accumulated timings, add ‘&reset’.

Alternatively, profile the python function calls executed to create the web page and display the profiling statistics in the web browser. To profile a page, add ‘?prof’ (or ‘&prof’) to the url. By default the statistics are sorted by cumulative time. To specify an alternative sort, add one or more ‘sort’ parameters, e.g., ‘&sort=time&sort=calls’. By default the display is limited to the first 40 function calls. To specify an alternative, add a limit parameter, e.g., ‘&limit=.50’. To write the profile data to a permanent file in PROFILE_LOG_BASE add ‘&log’. To strip the directory paths from the profile statistics, add ‘&strip’. (Note that the file and group summaries are also removed by ‘strip’.)

Methods

process_request

process_response

process_view

__init__()[source]