|
Server : Apache System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64 User : njnconst ( 1116) PHP Version : 8.4.18 Disable Function : NONE Directory : /usr/lib/python2.7/site-packages/werkzeug/middleware/ |
Upload File : |
�
./�_c @ s� d Z d d l m Z d d l Z d d l Z d d l Z d d l m Z y d d l m
Z
Wn! e k
r� d d l m
Z
n Xd e
f d � � YZ d S( s9
Application Profiler
====================
This module provides a middleware that profiles each request with the
:mod:`cProfile` module. This can help identify bottlenecks in your code
that may be slowing down your application.
.. autoclass:: ProfilerMiddleware
:copyright: 2007 Pallets
:license: BSD-3-Clause
i����( t print_functionN( t Stats( t Profilet ProfilerMiddlewarec B s2 e Z d Z e j d d d d d � Z d � Z RS( s Wrap a WSGI application and profile the execution of each
request. Responses are buffered so that timings are more exact.
If ``stream`` is given, :class:`pstats.Stats` are written to it
after each request. If ``profile_dir`` is given, :mod:`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 :meth:`str.format` with
the following fields available:
- ``{method}`` - The request method; GET, POST, etc.
- ``{path}`` - The request path or 'root' should one not exist.
- ``{elapsed}`` - The elapsed time of the request.
- ``{time}`` - The time of the request.
If it is a callable, it will be called with the WSGI ``environ``
dict and should return a filename.
:param app: The WSGI application to wrap.
:param stream: Write stats to this stream. Disable with ``None``.
:param sort_by: A tuple of columns to sort stats by. See
:meth:`pstats.Stats.sort_stats`.
:param restrictions: A tuple of restrictions to filter stats by. See
:meth:`pstats.Stats.print_stats`.
:param profile_dir: Save profile data files to this directory.
:param filename_format: Format string for profile data file names,
or a callable returning a name. See explanation above.
.. code-block:: python
from werkzeug.middleware.profiler import ProfilerMiddleware
app = ProfilerMiddleware(app)
.. versionchanged:: 0.15
Stats are written even if ``profile_dir`` is given, and can be
disable by passing ``stream=None``.
.. versionadded:: 0.15
Added ``filename_format``.
.. versionadded:: 0.9
Added ``restrictions`` and ``profile_dir``.
t timet callss/ {method}.{path}.{elapsed:.0f}ms.{time:.0f}.profc C s: | | _ | | _ | | _ | | _ | | _ | | _ d S( N( t _appt _streamt _sort_byt
_restrictionst _profile_dirt _filename_format( t selft appt streamt sort_byt restrictionst profile_dirt filename_format( ( s@ /tmp/pip-install-sTXtzD/Werkzeug/werkzeug/middleware/profiler.pyt __init__I s c
s� g � d � � f d � � � � � � f d � } t � } t j � } | j | � d j � � } t j � | } � j d k r%t � j � r� � j � � } nY � j j d � d d � j d � j
d � j d d � p� d
d | d d
t j � � } t j
j � j | � } | j | � n � j d k r�t | d � j �} | j � j � t d d d � j �t d j � j d d � � d � j �| j � j � t d d d d � j �n | g S( Nc s � | | | � � j S( N( t append( t statust headerst exc_info( t
response_bodyt start_response( s@ /tmp/pip-install-sTXtzD/Werkzeug/werkzeug/middleware/profiler.pyt catching_start_response\ s c s? � j � � � } � j | � t | d � r; | j � n d S( Nt close( R t extendt hasattrR ( t app_iter( R t environR R ( s@ /tmp/pip-install-sTXtzD/Werkzeug/werkzeug/middleware/profiler.pyt runapp` s
t t methodt REQUEST_METHODt patht PATH_INFOt /t .t roott elapsedg @�@R R t -iP t files
PATH: {!r}s
( t NoneR R t runcallt joinR
t callableR t formatt gett stript replacet osR$ t
dump_statsR R t
sort_statsR t printt print_statsR (
R R R R t profilet startt bodyR) t filenamet stats( ( R R R R R s@ /tmp/pip-install-sTXtzD/Werkzeug/werkzeug/middleware/profiler.pyt __call__Y s4
*
(( s timeR ( N( t __name__t
__module__t __doc__t syst stdoutR, R R>