
    d                         d Z g dZddlZddlZddlZddZddZej        j         e_         ej        j         e_          G d dej                  Z	d	 Z
d
 Zedk    r e             dS dS )zUPython interface for the 'lsprof' profiler.
   Compatible with the 'profile' module.
)runrunctxProfile    Nc                 ^    t          j        t                                        | ||          S N)
_pyprofile_Utilsr   r   )	statementfilenamesorts        /croot/python-split_1694437901252/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib/python3.11/cProfile.pyr   r      s%    W%%)))XtDDD    c                 b    t          j        t                                        | ||||          S r   )r	   r
   r   r   )r   globalslocalsr   r   s        r   r   r      s0    W%%,,Y-5t= = =r   c                   J    e Zd ZdZddZd Zd Zd Zd Zd Z	d	 Z
d
 Zd ZdS )r   a`  Profile(timer=None, timeunit=None, subcalls=True, builtins=True)

    Builds a profiler object using the specified timer function.
    The default timer is a fast built-in one based on real time.
    For custom timer functions returning integers, timeunit can
    be a float specifying a scale (i.e. how long each integer unit
    is, in seconds).
    r   c                     dd l }|                    |                                                               |                                           d S Nr   )pstatsStats
strip_dirs
sort_statsprint_stats)selfr   r   s      r   r   zProfile.print_stats)   sI    T%%''22488DDFFFFFr   c                     dd l }t          |d          5 }|                                  |                    | j        |           d d d            d S # 1 swxY w Y   d S )Nr   wb)marshalopencreate_statsdumpstats)r   filer   fs       r   
dump_statszProfile.dump_stats-   s    $ 	(LLQ'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(s   0AAAc                 V    |                                   |                                  d S r   )disablesnapshot_statsr   s    r   r    zProfile.create_stats3   s'    r   c                 l   |                                  }i | _        i }|D ]]}t          |j                  }|j        }||j        z
  }|j        }|j        }i }	|	|t          |j                  <   |||||	f| j        |<   ^|D ]}|j	        rt          |j                  }|j	        D ]}
	 |t          |
j                           }	n# t          $ r Y *w xY w|
j        }||
j        z
  }|
j        }|
j        }||	v r4|	|         }||d         z  }||d         z  }||d         z  }||d         z  }||||f|	|<   d S )Nr            )getstatsr"   labelcode	callcountreccallcount
inlinetime	totaltimeidcallsKeyError)r   entriescallersdictsentryfuncncccttctcallerssubentryprevs               r   r(   zProfile.snapshot_stats7   s   --//
 	7 	7E$$DBe((B!BBG+2LEJ(!2r2w6DJt 	3 	3E{ 3UZ(( % 3 3H!".r(-/@/@"A# ! ! ! !!+Bh33B!,B!+Bw&t}d1gd1gd1gd1g$&BNGDMM%	3 	3s   'C
CCc                 F    dd l }|j        }|                     |||          S r   )__main____dict__r   )r   cmdrD   dicts       r   r   zProfile.run]   s)     {{3d+++r   c                     |                                   	 t          |||           |                                  n# |                                  w xY w| S r   )enableexecr'   )r   rF   r   r   s       r   r   zProfile.runctxb   sL    	gv&&&LLNNNNDLLNNNNs	   < Ac                    |                                   	  ||i ||                                  S # |                                  w xY wr   )rI   r'   )r   r;   argskws       r   runcallzProfile.runcallk   sG    	4$$$LLNNNNDLLNNNNs	   2 Ac                 .    |                                   | S r   )rI   r)   s    r   	__enter__zProfile.__enter__r   s    r   c                 .    |                                   d S r   )r'   )r   exc_infos     r   __exit__zProfile.__exit__v   s    r   N)r   )__name__
__module____qualname____doc__r   r%   r    r(   r   r   rN   rP   rS    r   r   r   r      s         G G G G( ( (  !3 !3 !3L, , ,
          r   r   c                 ^    t          | t                    rdd| fS | j        | j        | j        fS )N~r   )
isinstancestrco_filenameco_firstlinenoco_name)r0   s    r   r/   r/   {   s6    $ EQ~ $"5t|DDr   c            
         dd l } dd l}dd l}dd l}ddlm} d} ||          }d|_        |                    dddd	d 
           |                    dddddt          |j	        j
                             |                    ddddd           |j        dd          s)|                                 |                    d           |                                \  }}||j        d d <   |j        $| j                            |j                  |_        t%          |          dk    r|j        rd}	|j        |d         d}
n|d         }|j                            d| j                            |                     t/          j        |          5 }t3          |                                |d          }	d d d            n# 1 swxY w Y   |dd d d}
	 t7          |	|
d |j        |j                   nL# t:          $ r+}d |_        |                    |j                   Y d }~nd }~ww xY w|                                 |S )Nr   )OptionParserzNcProfile.py [-o output_file_path] [-s sort] [-m module | scriptfile] [arg] ...)usageFz-oz	--outfileoutfilezSave stats to <outfile>)desthelpdefaultz-sz--sortr   z?Sort order when printing to stdout, based on pstats.Stats classr,   )rd   re   rf   choicesz-mmodule
store_truezProfile a library module)rd   actionre   rf   r+   z(run_module(modname, run_name='__main__'))
run_modulemodnamerJ   rD   )__file__rT   __package__
__cached__) ossysrunpyr   optparsera   allow_interspersed_args
add_optionsortedr   sort_arg_dict_defaultargvprint_usageexit
parse_argsrc   pathabspathlenrh   rk   insertdirnameio	open_codecompilereadr   r   BrokenPipeErrorstdouterrno)rp   rq   rr   r   ra   rb   parseroptionsrL   r0   globsprognamefpexcs                 r   mainr      s   IIIJJJLLLMMM%%%%%%\E\&&&F%*F"
dKi&  6 6 6
dH6Nv|9::  < < < d,'  8 8 8 8ABB< ''))OWdCHQQQK "'//'/::
4yy1}}> 	=D#.7 EE
 AwHHOOArwx88999h'' <2rwwyy(F;;< < < < < < < < < < < < < < < %&#"	 E	 4gow|DDDD 	  	  	 CJHHSY	 
 	Ms*   $GG	G	G6 6
H+ !H&&H+rD   )Nr   )rW   __all___lsprofr   profiler	   r   r   Profilerr   r/   r   rT   rX   r   r   <module>r      s     '
&
&  				    
E E E E= = = = n$"*[ [ [ [ [g [ [ [~E E E8 8 8v zDFFFFF r   