Your IP : 18.119.255.183


Current Path : /opt/alt/python39/lib64/python3.9/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/__pycache__/pstats.cpython-39.opt-2.pyc

a

R�f�r�@s�ddlZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZgd�Z
Gdd�dee�Ze
d	d
�Gdd�d��Ze
d	d
�Gd
d�d��ZGdd�d�ZGdd�d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zed!k�r�ddlZzddlZWne�y(Yn0Gd"d#�d#ej�Z e!ej"�d$k�rXej"d$Z#ndZ#zPe e#�Z$ej"d%d�D]Z%e$�&e%��qte'd&e$j(d'�e$�)�e'd(e$j(d'�Wne*�y�Yn0dS))�N)�Enum)�
cmp_to_key)�	dataclass)�Dict)�Stats�SortKey�FunctionProfile�StatsProfilec@s8eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
d�ZdS)
r)�calls�ncalls)�
cumulative�cumtime)�filename�module�line�name�nfl�pcalls�stdname)�time�tottimecGs@|d}t�||�}||_|dd�D]}||j|<q&||_|S�Nr�)�str�__new__�_value_�_value2member_map_Z_all_values)�cls�values�value�objZother_value�r!�+/opt/alt/python39/lib64/python3.9/pstats.pyr/szSortKey.__new__N)
�__name__�
__module__�__qualname__ZCALLSZ
CUMULATIVEZFILENAMEZLINE�NAMEZNFLZPCALLSZSTDNAMEZTIMErr!r!r!r"r$srT)Zunsafe_hashc@sFeZdZUeed<eed<eed<eed<eed<eed<eed<dS)	rrr�percall_tottimer
�percall_cumtime�	file_name�line_numberN)r#r$r%�int�__annotations__�floatrr!r!r!r"r9s
rc@s&eZdZUeed<eeefed<dS)r	�total_tt�
func_profilesN)r#r$r%r-r,rrrr!r!r!r"r	Cs
r	c@s�eZdZdd�dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdddddddddddddd�
Z	dd�Z
dd�Zdd�Zdd �Z
d!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd8d2d3�Zd4d5�Zd6d7�ZdS)9rN)�streamcGsF|ptj|_t|�sd}n|d}|dd�}|�|�|j|�dSr)�sys�stdoutr0�len�init�add)�selfr0�args�argr!r!r"�__init__ks
zStats.__init__cCs�d|_g|_d|_d|_d|_d|_d|_t�|_i|_	i|_
|�|�z|��Wn6t
y�td|jrv|jdnd|jd��Yn0dS)NrzInvalid timing data %s������file)�all_callees�files�fcn_listr.�total_calls�
prim_calls�max_name_len�set�	top_level�stats�
sort_arg_dict�
load_stats�get_top_level_stats�	Exception�printr0)r6r8r!r!r"r4us(
��z
Stats.initcCs�|duri|_dSt|t�r�t|d��}t�|�|_Wd�n1sH0Yz"t�|�}t�	|j
�d|}WnYn0|g|_n t|d�r�|�
�|j|_i|_|js�td|j|f��dS)N�rbz    �create_statsz.Cannot create or construct a %r object from %r)rF�
isinstancer�open�marshal�load�os�statr�ctime�st_mtimer?�hasattrrM�	TypeError�	__class__)r6r8�fZ
file_statsr!r!r"rH�s*
*


�zStats.load_statscCs�|j��D]p\}\}}}}}|j|7_|j|7_|j|7_d|vrZ|j�|�tt|��|j	kr
tt|��|_	q
dS)N)ZjprofilerZprofiler)
rF�itemsrArBr.rEr5r3�func_std_stringrC)r6�func�cc�nc�tt�ct�callersr!r!r"rI�szStats.get_top_level_statscGs�|s|St|�D]�}t|�t|�kr,t|�}|j|j7_|j|j7_|j|j7_|j|j7_|jD]}|j�|�qr|j	|j	kr�|j	|_	d|_
|j��D]<\}}||jvr�|j|}nddddif}t
||�|j|<q�q|S�Nr)�reversed�typerr?rArBr.rEr5rCr@rFrZ�add_func_stats)r6�arg_list�itemr\rSZ
old_func_statr!r!r"r5�s(

z	Stats.addcCs<t|d��}t�|j|�Wd�n1s.0YdS)N�wb)rOrP�dumprF)r6rrYr!r!r"�
dump_stats�szStats.dump_stats)))rr:z
call count)))�r:zcumulative time))��rz	file name))��rzline number))��rz
function name))rprlrnzname/file/line)))rr:zprimitive call count)))�rz
standard name)))�r:z
internal time)
r
rr
rrrrrrrrrrcCst|jsni|_}i}|j��D]>\}}|}|r|s4q||vrFd||<q|||<|dd�}q*q|D]
}||=qb|jS)Nrr:)rG�sort_arg_dict_defaultrZ)r6�dictZbad_list�word�tupZfragmentr!r!r"�get_sort_arg_defs�s 
zStats.get_sort_arg_defscGs\|sd|_|St|�dkrBt|dt�rBddddd�|dg}n:t|�dkr||dd�D] }t|�t|d�krZtd	��qZ|��}d
}d|_d}|D]B}t|t�r�|j	}|||d}|j|||d7_d}q�g}|j
��D]4\}\}	}
}}}
|�|	|
||f|t
|�|f�q�|jtt|�j�d
�g|_}|D]}|�|d��qB|S)Nrrrr
rr)r:rrrsrszCan't have mixed argument typer!r;z, )�keyr:)r@r3rNr+rdrWrx�	sort_typerrrFrZ�appendr[�sortr�	TupleComp�compare)r6Zfieldr8Z
sort_arg_defsZ
sort_tupleZ	connectorrvZ
stats_listr\r]r^r_r`rar@�tupler!r!r"�
sort_stats�sF��


�
zStats.sort_statscCs|jr|j��|S�N)r@�reverse�r6r!r!r"�
reverse_orders
zStats.reverse_ordercCs�|j}i|_}d}|��D]�\}\}}}}}	t|�}
tt|
��|krRtt|
��}i}|	��D]\}}
|
|t|�<q^|
|vr�t||
|||||f�||
<q|||||f||
<q|j}t�|_}|D]}|�t|��q�||_	d|_
d|_|Srb)rFrZ�func_strip_pathr3r[rerErDr5rCr@r>)r6ZoldstatsZnewstatsrCr\r]r^r_r`raZnewfuncZ
newcallers�func2�callerZold_topZnew_topr!r!r"�
strip_dirss0
�
zStats.strip_dirsc
Cst|jr
dSi|_}|j��D]P\}\}}}}}||vr@i||<|��D]$\}}	||vr`i||<|	|||<qHqdSr�)r>rFrZ)
r6r>r\r]r^r_r`rar�r�r!r!r"�calc_callees5s
zStats.calc_calleescCs|}t|t�rnzt�|�}Wn(tjyD|d|7}||fYS0g}|D]}|�t|��rN|�|�qNnzt|�}t|t	�r�d|kr�dkr�nnt
||d�}|d|�}n2t|t
�r�d|kr�|kr�nn|}|d|�}t|�t|�k�r|dt|�t|�|f7}||fS)Nz#   <Invalid regular expression %r>
gg�?g�?rz6   List reduced from %r to %r due to restriction <%r>
)rNr�re�compile�error�searchr[r{r3r-r+)r6Zsel�list�msgZnew_listZrexr\�countr!r!r"�eval_print_amountHs.
""�zStats.eval_print_amountc	Cs|jr|jdd�nt|j���}|s0tdi�Stt|j��}i}t||�}|D]�}|j|\}}}}	}
|\}}}
||kr�t|�nt|�dt|�}tt|��}|dkr�dntt||��}tt|	��}|dkr�dntt|	|��}t	|||||||�}|||
<qP|S)Nr�/r:)
r@r�rF�keysr	r-�f8r.rr)r6Z	func_listr.r/Z
stats_profiler\r]r^r_r`rar)r*�	func_namerrr'r
r(Zfunc_profiler!r!r"�get_stats_profilebs2"


$�	
zStats.get_stats_profilecCs�|j}|jr*|jdd�}d|jd}nt|j���}d}|D]}|�|||�\}}q@t|�}|sld|fSt||j	d�|t|j�kr�d}|D] }tt
|��|kr�tt
|��}q�|d|fS)Nz   Ordered by: �
z!   Random listing order was used
rr<rs)rCr@rzr�rFr�r�r3rKr0r[)r6Zsel_list�widthZ	stat_listr�Z	selectionr�r\r!r!r"�get_print_list�s$zStats.get_print_listcGs�|jD]}t||jd�q|jr,t|jd�d}|jD]}t|t|�|jd�q6t||jdd|jd�|j|jkr�td|jd|jd�td|j|jd�t|jd�|�|�\}}|r�|�	�|D]}|�
|�q�t|jd�t|jd�|S)Nr<�        zfunction calls� ��endr=z(%d primitive calls)zin %.3f seconds)r?rKr0rE�func_get_function_namerArBr.r��print_title�
print_line)r6�amountr�indentr\r�r�r!r!r"�print_stats�s(

zStats.print_statscGsz|�|�\}}|rv|��|�|d�|D]2}||jvrN|�|||j|�q*|�||i�q*t|jd�t|jd�|S)Nz	called...r<)r�r��print_call_headingr>�print_call_linerKr0)r6r�r�r�r\r!r!r"�
print_callees�s
zStats.print_calleesc
Gsh|�|�\}}|rd|�|d�|D](}|j|\}}}}}	|�|||	d�q"t|jd�t|jd�|S)Nzwas called by...z<-r<)r�r�rFr�rKr0)
r6r�r�r�r\r]r^r_r`rar!r!r"�
print_callers�szStats.print_callersc
Csvtd�|�||jd�d}|j��D]0\}}}}}|r&tt|����}	t|	t�}qXq&|rrtd|d|jd�dS)Nz	Function r<Fr�z    ncalls  tottime  cumtime)	rK�ljustr0rFr�next�iterrNr)
r6�	name_sizeZcolumn_titleZ	subheaderr]r^r_r`rarr!r!r"r��s
zStats.print_call_heading�->cCstt|��|�|d|jd�|s2t|jd�dSt|���}d}|D]�}t|�}||}	t|	t�r�|	\}
}}}
|
|kr�d|
|f}n
d|
f}d|�dd	t	|��t
|�t
|
�|f}|d
}n$d||	t
|j|d�f}|d}t||||jd�d}qFdS)
Nr�r�r<r;z%d/%dz%dz%s %s %s  %srrrsrz	%s(%r) %srk)rKr[r�r0�sortedr�rNr�rjustr3r�rF)r6r��sourceZ	call_dictZarrowZclistr�r\rrr^r]r_r`ZsubstatsZ
left_widthr!r!r"r��s,

�
zStats.print_call_linecCs"tdd|jd�td|jd�dS)Nz-   ncalls  tottime  percall  cumtime  percallr�r�zfilename:lineno(function)r<�rKr0r�r!r!r"r��szStats.print_titlecCs�|j|\}}}}}t|�}||kr4|dt|�}t|�d�d|jd�tt|�d|jd�|dkrxtdd|jd�ntt||�d|jd�tt|�d|jd�|dkr�tdd|jd�ntt||�d|jd�tt|�|jd�dS)Nr��	r�r�rr�r<)rFrrKr�r0r�r[)r6r\r]r^r_r`ra�cr!r!r"r��szStats.print_line)r�)r#r$r%r9r4rHrIr5rjrtrxr�r�r�r�r�r�r�r�r�r�r�r�r�r�r!r!r!r"rIsF"

�'#
rc@seZdZdd�Zdd�ZdS)r}cCs
||_dSr���comp_select_list)r6r�r!r!r"r9szTupleComp.__init__cCsF|jD]:\}}||}||}||kr0|S||kr|SqdSrbr�)r6�left�right�index�	direction�l�rr!r!r"r~s

zTupleComp.compareN)r#r$r%r9r~r!r!r!r"r}	sr}cCs|\}}}tj�|�||fSr�)rR�path�basename)r�rrrr!r!r"r�"s
r�cCs|dS)Nrsr!)r\r!r!r"r�&sr�cCsN|dd�dkrB|d}|�d�r<|�d�r<d|dd�S|Snd|SdS)	Nrs)�~r�<�>z{%s}rr:z	%s:%d(%s))�
startswith�endswith)r�rr!r!r"r[)sr[cCs@|\}}}}}|\}}}	}
}||||||	||
t||�fSr�)�add_callers)�targetr�r]r^r_r`raZt_ccZt_ncZt_ttZt_ctZ	t_callersr!r!r"re:s
�recCs�i}|��D]\}}|||<q|��D]V\}}||vrtt|t�rbtdd�t|||�D��||<q||||7<q&|||<q&|S)Ncss|]\}}||VqdSr�r!)�.0�i�jr!r!r"�	<genexpr>J�zadd_callers.<locals>.<genexpr>)rZrNr�zip)r�r�Znew_callersr\r�r!r!r"r�As

"
r�cCsd}|��D]}||7}q|Srb)r)rar^r
r!r!r"�count_callsRs
r�cCsd|S)Nz%8.3fr!)�xr!r!r"r�]sr��__main__c@s�eZdZd6dd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�ZdS)7�ProfileBrowserNcCs6tj�|�d|_d|_tj|_|dur2|�|�dS)N�% )	�cmd�Cmdr9�promptrFr1r2r0�do_read)r6�profiler!r!r"r9lszProfileBrowser.__init__c	Cs�|��}g}|D]�}z|�t|��WqWnty<Yn0z<t|�}|dksX|dkrjtd|jd�Wq|�|�WqWnty�Yn0|�|�q|jr�t|j|�|�ntd|jd�dS)Nrrz#Fraction argument must be in [0, 1]r<�No statistics object is loaded.)	�splitr{r+�
ValueErrorr-rKr0rF�getattr)r6�fnrr7Z	processedZtermZfracr!r!r"�genericts,
zProfileBrowser.genericcCsXtd|jd�td|jd�td|jd�td|jd�td|jd�td|jd�dS)NzArguments may be:r<z0* An integer maximum number of entries to print.z:* A decimal fractional number between 0 and 1, controllingz-  what fraction of selected entries to print.z8* A regular expression; only entries with function namesz  that match it are printed.r�r�r!r!r"�generic_help�szProfileBrowser.generic_helpc
Csf|jrTz|j�|�WqbtyP}z"td||f|jd�WYd}~qbd}~00ntd|jd�dS)Nz$Failed to load statistics for %s: %sr<r�r)rFr5�OSErrorrKr0)r6r�er!r!r"�do_add�s.zProfileBrowser.do_addcCstd|jd�dS)Nz>Add profile info from given file to current statistics object.r<r�r�r!r!r"�help_add�szProfileBrowser.help_addcCs|�d|�S)Nr��r��r6rr!r!r"�
do_callees�szProfileBrowser.do_calleescCstd|jd�|��dS)Nz6Print callees statistics from the current stat object.r<�rKr0r�r�r!r!r"�help_callees�szProfileBrowser.help_calleescCs|�d|�S)Nr�r�r�r!r!r"�
do_callers�szProfileBrowser.do_callerscCstd|jd�|��dS)Nz6Print callers statistics from the current stat object.r<r�r�r!r!r"�help_callers�szProfileBrowser.help_callerscCstd|jd�dS)Nr;r<rr�r�r!r!r"�do_EOF�szProfileBrowser.do_EOFcCstd|jd�dS�NzLeave the profile browser.r<r�r�r!r!r"�help_EOF�szProfileBrowser.help_EOFcCsdS)Nrr!r�r!r!r"�do_quit�szProfileBrowser.do_quitcCstd|jd�dSr�r�r�r!r!r"�	help_quit�szProfileBrowser.help_quitc
Cs�|r�zt|�|_WnvtyL}z"t|jd|jd�WYd}~dSd}~0ty�}z&t|jjd||jd�WYd}~dSd}~00|d|_	n6t
|j	�dkr�|j	dd�}|�|�ntd|jd�dS)	Nrr<�:r�rs���z1No statistics object is current -- cannot reload.r)rrFr�rKr7r0rJrXr#r�r3r�)r6r�errr!r!r"r��szProfileBrowser.do_readcCs td|jd�td|jd�dS)Nz+Read in profile data from a specified file.r<z*Without argument, reload the current file.r�r�r!r!r"�	help_read�szProfileBrowser.help_readcCs$|jr|j��ntd|jd�dS)Nr�r<r)rFr�rKr0r�r!r!r"�
do_reverse�szProfileBrowser.do_reversecCstd|jd�dS)Nz/Reverse the sort order of the profiling report.r<r�r�r!r!r"�help_reverse�szProfileBrowser.help_reversecs�|jstd|jd�dS|j���|rRt�fdd�|��D��rR|jj|���n<td|jd�tj�	�D]"\}}td||df|jd�qjdS)	Nr�r<c3s|]}|�vVqdSr�r!)r�r��Zabbrevsr!r"r��r�z)ProfileBrowser.do_sort.<locals>.<genexpr>z/Valid sort keys (unique prefixes are accepted):z%s -- %srr)
rFrKr0rx�allr�r�rrtrZ)r6rryrr!r�r"�do_sort�s
zProfileBrowser.do_sortcCs td|jd�td|jd�dS)Nz.Sort profile data according to specified keys.r<z3(Typing `sort' without arguments lists valid keys.)r�r�r!r!r"�	help_sort�szProfileBrowser.help_sortcs�fdd�tjD�S)Ncsg|]}|���r|�qSr!)r�)r��a��textr!r"�
<listcomp>�r�z0ProfileBrowser.complete_sort.<locals>.<listcomp>)rrt)r6r�r7r!r�r"�
complete_sort�szProfileBrowser.complete_sortcCs|�d|�S)Nr�r�r�r!r!r"�do_stats�szProfileBrowser.do_statscCstd|jd�|��dS)Nz.Print statistics from the current stat object.r<r�r�r!r!r"�
help_stats�szProfileBrowser.help_statscCs$|jr|j��ntd|jd�dS)Nr�r<)rFr�rKr0r�r!r!r"�do_strip�szProfileBrowser.do_stripcCstd|jd�dS)Nz<Strip leading path information from filenames in the report.r<r�r�r!r!r"�
help_strip�szProfileBrowser.help_stripcCstd|jd�dS)NzShow help for a given command.r<r�r�r!r!r"�	help_help�szProfileBrowser.help_helpcCs|r|SdSr�r!)r6�stoprr!r!r"�postcmd�szProfileBrowser.postcmd)N)r#r$r%r9r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr!r!r!r"r�ks4
	r�rrsz*Welcome to the profile statistics browser.r<zGoodbye.)+r1rRrrPr��enumr�	functoolsrZdataclassesr�typingr�__all__rrrr	rr}r�r�r[rer�r�r�r#r��readline�ImportErrorr�r�r3�argvZinitprofileZbrowserr�r�rKr0Zcmdloop�KeyboardInterruptr!r!r!r"�<module>s\	C


?>