ó
    pñ:iº  ã                  óÌ   • S r SSKJr  SSKrSSKrSSKrSSKrSSK	J
r
   SSKJr  \R                  (       a  SSKJr  SSKJr  SSKJr   " S	 S
5      rg! \ a	    SSKJr   N<f = f)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   • \ rS rSrSr\R                  SSSS4             S
S jjr      SS jrS	r	g)ÚProfilerMiddlewareé"   aa  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``.
)ÚtimeÚcalls© Nz/{method}.{path}.{elapsed:.0f}ms.{time:.0f}.profc                óL   • Xl         X l        X0l        X@l        XPl        X`l        g ©N)Ú_appÚ_streamÚ_sort_byÚ_restrictionsÚ_profile_dirÚ_filename_format)ÚselfÚappÚstreamÚsort_byÚrestrictionsÚprofile_dirÚfilename_formats          Ú_/srv/projetos/modelo_ml_acdoc/venv/lib/python3.13/site-packages/werkzeug/middleware/profiler.pyÚ__init__ÚProfilerMiddleware.__init__Y   s%   € ð Œ	ØŒØŒØ)ÔØ'ÔØ /Õó    c                ó$  ^ ^^^^• / mSUU4S jjmSUUUU 4S jjn[        5       n[        R                  " 5       nUR                  U5        SR                  T5      n[        R                  " 5       U-
  nT R                  bå  [        T R                  5      (       a0  US-  [        R                  " 5       S.TS'   T R                  T5      nO`T R                  R                  TS   TS   R                  S	5      R                  S	S
5      =(       d    SUS-  [        R                  " 5       S9n[        R                  R                  T R                  U5      nUR                  U5        T R                  b›  [        UT R                  S9n	U	R                  " T R                   6   [#        ST R                  S9  TR%                  SS5      n
[#        SU
< 3T R                  S9  U	R&                  " T R(                  6   [#        S S3T R                  S9  U/$ )Nc                ó.   >• T" XU5        TR                   $ r   )Úappend)ÚstatusÚheadersÚexc_infoÚresponse_bodyÚstart_responses      €€r   Úcatching_start_responseÚ<ProfilerMiddleware.__call__.<locals>.catching_start_responsen   s   ø€ Ù˜6¨HÔ5Ø ×'Ñ'Ð'r!   c                 óº   >• TR                  T[        R                  " ST5      5      n TR                  U 5        [	        U S5      (       a  U R                  5         g g )Nr   Úclose)r   ÚtÚcastÚextendÚhasattrr-   )Úapp_iterr*   Úenvironr(   r   s    €€€€r   ÚrunappÚ+ProfilerMiddleware.__call__.<locals>.runappr   sN   ø€ Ø—y‘yØœŸš Ð1HÓIóˆHð × Ñ  Ô*ä�x ×)Ñ)Ø—‘Õ ð *r!   r!   g     @�@)Úelapsedr   zwerkzeug.profilerÚREQUEST_METHODÚ	PATH_INFOÚ/Ú.Úroot)ÚmethodÚpathr6   r   )r   zP--------------------------------------------------------------------------------)ÚfileÚ zPATH: Ú
r   )ÚreturnÚNone)r   r   ÚruncallÚjoinr   Úcallabler   ÚformatÚstripÚreplaceÚosr=   Ú
dump_statsr   r   Ú
sort_statsr   ÚprintÚgetÚprint_statsr   )r   r3   r)   r4   ÚprofileÚstartÚbodyr6   ÚfilenameÚstatsÚ	path_infor*   r(   s   ```        @@r   Ú__call__ÚProfilerMiddleware.__call__i   s»  ü€ ð &(ˆ÷	(ð 	(÷	!ò 	!ô “)ˆÜ—	’	“ˆØ�‰˜ÔØ�x‰x˜Ó&ˆÜ—)’)“+ Ñ%ˆà×ÑÑ(Ü˜×-Ñ-×.Ñ.à&¨Ñ/Ü ŸIšI›Kñ0�Ð+Ñ,ð  ×0Ñ0°Ó9‘à×0Ñ0×7Ñ7Ø"Ð#3Ñ4Ø  Ñ-×3Ñ3°CÓ8×@Ñ@ÀÀcÓJ×TÈfØ# fÑ,ÜŸš›ð	 8ð �ô —w‘w—|‘| D×$5Ñ$5°xÓ@ˆHØ×Ñ˜xÔ(à�<‰<Ñ#Ü˜'¨$¯,©,Ñ7ˆEØ×Ò˜dŸm™mÑ,Ü�( §¡Ò.ØŸ™ K°Ó4ˆIÜ�F˜9™-Ð(¨t¯|©|Ò<Ø×Ò˜t×1Ñ1Ñ2Ü�X�J˜b�/¨¯©Ò5àˆvˆr!   )r   r   r   r   r   r   )r   r   r   zt.IO[str] | Noner   zt.Iterable[str]r   zt.Iterable[str | int | float]r   z
str | Noner   ÚstrrA   rB   )r3   r   r)   r   rA   zt.Iterable[bytes])
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ÚsysÚstdoutr   rU   Ú__static_attributes__r   r!   r   r
   r
   "   sƒ   † ñ4ðr $'§:¡:Ø#4Ø68Ø"&ØPð0àð0ð !ð0ð !ð	0ð
 4ð0ð  ð0ð ð0ð 
õ0ð 2Ø&ð2Ø8Eð2à	÷2r!   r
   )r\   Ú
__future__r   Úos.pathrI   r]   r   Útypingr.   Úpstatsr   ÚcProfiler   ÚImportErrorrO   ÚTYPE_CHECKINGÚ_typeshed.wsgir   r   r   r
   r   r!   r   Ú<module>rh      sX   ðñõ #ã Û 
Û Û Ý ð Ý ð ‡?‡?Ý,Ý.Ý.÷yò yøð ó  ßð ús    A ÁA#Á"A#