
    .`i                    l    d dl mZ d dlZd dlmZ d dlmZ d dlmZ ej	        ddd            Z
dddZdS )    )annotationsN)Callablewraps)Any	save_file
str | Nonec              #    K   ddl }|                                }|                                 	 dV  |                                 | r| dk    r|                    |            dS |                    d           dS # |                                 | r| dk    r|                    |            w |                    d           w xY w)zRun a cprofile

    Args:
        save_file: path to save the profile result. "1" or
            None will result in printing to stdout.
    r   N1cumtime)sort)cProfileProfileenabledisable
dump_statsprint_stats)r   r   profs      h/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/vllm/utils/profiling.pycprofile_contextr      s       OOODKKMMM- 	-c))OOI&&&&&),,,,,	 	 	-c))OOI&&&&),,,,s   A? ?A
C	Tenabledboolc                     d fd}|S )zDecorator to profile a Python method using cProfile.

    Args:
        save_file: Path to save the profile result.
            If "1", None, or "", results will be printed to stdout.
        enabled: Set to false to turn this into a no-op
    funcr   c                D     t                     d fd            }|S )Nargsr   kwargsc                 z    s | i |S t                    5   | i |cd d d            S # 1 swxY w Y   d S N)r   )r   r   r   r   r   s     r   wrapperz,cprofile.<locals>.decorator.<locals>.wrapper-   s     -tT,V,,,!),, - -tT,V,,- - - - - - - - - - - - - - - - - -s   044)r   r   r   r   r   )r   r    r   r   s   ` r   	decoratorzcprofile.<locals>.decorator,   sC    	t	- 	- 	- 	- 	- 	- 	- 
	-     )r   r    )r   r   r!   s   `` r   cprofiler$   #   s/    
 
 
 
 
 
 
 r"   r   )r   r	   )NT)r   r	   r   r   )
__future__r   
contextlibcollections.abcr   	functoolsr   typingr   contextmanagerr   r$   r#   r"   r   <module>r+      s    # " " " " "     $ $ $ $ $ $             - - - - -,      r"   