+
    Nj                        R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RI	H
t
  ^ RIHt ]P                  '       d   ^ RIHt ^ RIHt ^ RIHt  ! R R	4      tR#   ] d
    ^ RIHt  L?i ; i)
a9  
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
)annotationsN)Stats)Profile)StartResponse)WSGIApplication)WSGIEnvironmentc                  T    ] tR t^"tRt]P                  R	R
RR3R R lltR R ltRt	R# )ProfilerMiddlewareaa  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 in milliseconds.
-   ``{time}`` - The time of the request.

If it is a callable, it will be called with the WSGI ``environ`` and
be expected to return a filename string. The ``environ`` dictionary
will also have the ``"werkzeug.profiler"`` key populated with a
dictionary containing the following fields (more may be added in the
future):
-   ``{elapsed}`` - The elapsed time of the request in milliseconds.
-   ``{time}`` - The time of the request.

: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:: 3.0
    Added the ``"werkzeug.profiler"`` key to the ``filename_format(environ)``
    parameter with the  ``elapsed`` and ``time`` fields.

.. 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``.
Nz/{method}.{path}.{elapsed:.0f}ms.{time:.0f}.profc               4    V ^8  d   QhRRRRRRRRR	R
RRRR/# )   appr   streamzt.IO[str] | Nonesort_byzt.Iterable[str]restrictionszt.Iterable[str | int | float]profile_dirz
str | Nonefilename_formatstrreturnNone )formats   "^/data/cameron/venvs/serve_omidlab/lib/python3.14/site-packages/werkzeug/middleware/profiler.py__annotate__ProfilerMiddleware.__annotate__Y   sP     0 00 !0 !	0
 40  0 0 
0    c                	N    Wn         W n        W0n        W@n        WPn        W`n        R # N)_app_stream_sort_by_restrictions_profile_dir_filename_format)selfr   r   r   r   r   r   s   &&&&&&&r   __init__ProfilerMiddleware.__init__Y   s%     	)' /r   c               $    V ^8  d   QhRRRRRR/# )r   environr   start_responser   r   zt.Iterable[bytes]r   )r   s   "r   r   r   i   s$     2 2&28E2	2r   c                	z  a aaaa . oRVV3R lloR VVVV 3R llp\        4       p\        P                  ! 4       pVP                  V4       RP                  S4      p\        P                  ! 4       V,
          pS P                  e   \        S P                  4      '       d6   RVR,          R\        P                  ! 4       /SR&   S P                  S4      pMpS P                  P                  SR	,          SR
,          P                  R4      P                  RR4      ;'       g    RVR,          \        P                  ! 4       R7      p\        P                  P                  S P                  V4      pVP                  V4       S P                  e   \        VS P                  R7      p	V	P                  ! S P                   !   \#        RS P                  R7       SP%                  R
R4      p
\#        RV
: 2S P                  R7       V	P&                  ! S P(                  !   \#        R R2S P                  R7       V.# )Nc                .   < S! WV4       SP                   # r   )append)statusheadersexc_inforesponse_bodyr(   s   &&&r   catching_start_response<ProfilerMiddleware.__call__.<locals>.catching_start_responsen   s    6H5 '''r   c                   V ^8  d   QhRR/# )r   r   r   r   )r   s   "r   r   1ProfilerMiddleware.__call__.<locals>.__annotate__r   s     	! 	! 	!r   c                    < SP                  S\        P                  ! R S4      4      p SP                  V 4       \	        V R4      '       d   V P                  4        R# R# )r   closeN)r   tcastextendhasattrr5   )app_iterr0   r'   r/   r#   s    r   runapp+ProfilerMiddleware.__call__.<locals>.runappr   sN    yy1HIH   *x))  *r   r   elapsedg     @@timezwerkzeug.profilerREQUEST_METHOD	PATH_INFO/.root)methodpathr=   r>   )r   )file zPATH: 
r   zP--------------------------------------------------------------------------------)r   r>   runcalljoinr!   callabler"   r   stripreplaceosrE   
dump_statsr   r   
sort_statsr   printgetprint_statsr    )r#   r'   r(   r;   profilestartbodyr=   filenamestats	path_infor0   r/   s   fff        @@r   __call__ProfilerMiddleware.__call__i   s    &(	( 	(	! 	! )		xx&))+%(--..w/DIIK0+,  0090077"#34 -33C8@@cJTTf#f,	 8  ww||D$5$5x@Hx(<<#'$,,7Edmm,(.K4IF9-(t||<t112XJb/5vr   )r   r"   r!   r    r   r   )r>   callsr   )
__name__
__module____qualname____firstlineno____doc__sysstdoutr$   rZ   __static_attributes__r   r   r   r	   r	   "   s,    4r $'::#468"&P0 2 2r   r	   )ra   
__future__r   os.pathrN   rb   r>   typingr6   pstatsr   cProfiler   ImportErrorrT   TYPE_CHECKING_typeshed.wsgir   r   r   r	   r   r   r   <module>rm      sZ    #  
      ???,..y y    s   A A&%A&