ok

Mini Shell

Direktori : /opt/alt/python311/lib64/python3.11/__pycache__/
Upload File :
Current File : //opt/alt/python311/lib64/python3.11/__pycache__/pstats.cpython-311.pyc

�

�f�r���dZddlZddlZddlZddlZddlZddlmZmZddl	m
Z
ddlmZddl
mZgd�Zee��Gd�d	����Zed
���Gd�d
����Zed
���Gd�d����ZGd�d��ZGd�d��Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zedkr�ddlZ	ddlZn#e$rYnwxYwGd�dej ��Z!e"ej#��dkrej#dZ$ndZ$	e!e$��Z%ej#dd�D]Z&e%�'e&���e(d e%j)�!��e%�*��e(d"e%j)�!��dS#e+$rYdSwxYwdS)#z3Class for printing reports on profiled python code.�N)�StrEnum�_simple_enum)�
cmp_to_key)�	dataclass)�Dict)�Stats�SortKey�FunctionProfile�StatsProfilec�8�eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
�ZdS)r	)�calls�ncalls)�
cumulative�cumtime)�filename�module�line�name�nfl�pcalls�stdname)�time�tottimec��|d}t�||��}||_|dd�D]}||j|<�
||_|S�Nr�)�str�__new__�_value_�_value2member_map_�_all_values)�cls�values�value�obj�other_values     �-/opt/alt/python311/lib64/python3.11/pstats.pyrzSortKey.__new__0sX���q�	���k�k�#�u�%�%�����!�!�"�"�:�	6�	6�K�25�C�"�;�/�/� ����
�N)
�__name__�
__module__�__qualname__�CALLS�
CUMULATIVE�FILENAME�LINE�NAME�NFL�PCALLS�STDNAME�TIMEr�r(r'r	r	$sP�������E�(�J�#�H��D��D�
�C�
�F��G��D�����r(r	T)�unsafe_hashc�V�eZdZUeed<eed<eed<eed<eed<eed<eed<dS)	r
rr�percall_tottimer�percall_cumtime�	file_name�line_numberN)r)r*r+r�__annotations__�float�intr5r(r'r
r
:sZ��������K�K�K�
�N�N�N�����
�N�N�N������N�N�N������r(r
c�8�eZdZUdZeed<eeefed<dS)rz0Class for keeping track of an item in inventory.�total_tt�
func_profilesN)	r)r*r+�__doc__r=r<rrr
r5r(r'rrDs7�������:�:��O�O�O���_�,�-�-�-�-�-�-r(rc��eZdZdZdd�d�Zd�Zd�Zd�Zd�Zd	�Z	d
d
dddd
dddddddd�
Z
d�Zd�Zd�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd$d!�Zd"�Zd#�ZdS)%ra�This class is used for creating reports from data generated by the
    Profile class.  It is a "friend" of that class, and imports data either
    by direct access to members of Profile class, or by reading in a dictionary
    that was emitted (via marshal) from the Profile class.

    The big change from the previous Profiler (in terms of raw functionality)
    is that an "add()" method has been provided to combine Stats from
    several distinct profile runs.  Both the constructor and the add()
    method now take arbitrarily many file names as arguments.

    All the print methods now take an argument that indicates how many lines
    to print.  If the arg is a floating point number between 0 and 1.0, then
    it is taken as a decimal percentage of the available lines to be printed
    (e.g., .1 means print 10% of all available lines).  If it is an integer,
    it is taken to mean the number of lines of data that you wish to have
    printed.

    The sort_stats() method now processes some additional options (i.e., in
    addition to the old -1, 0, 1, or 2 that are respectively interpreted as
    'stdname', 'calls', 'time', and 'cumulative').  It takes either an
    arbitrary number of quoted strings or SortKey enum to select the sort
    order.

    For example sort_stats('time', 'name') or sort_stats(SortKey.TIME,
    SortKey.NAME) sorts on the major key of 'internal function time', and on
    the minor key of 'the name of the function'.  Look at the two tables in
    sort_stats() and get_sort_arg_defs(self) for more examples.

    All methods return self, so you can string together commands like:
        Stats('foo', 'goo').strip_dirs().sort_stats('calls').                            print_stats(5).print_callers(5)
    N)�streamc��|ptj|_t|��sd}n|d}|dd�}|�|��|j|�dSr)�sys�stdoutrD�len�init�add)�selfrD�args�args    r'�__init__zStats.__init__ls[���*��
����4�y�y�	��C�C��q�'�C�����8�D��	�	�#�������$����r(c�v�d|_g|_d|_d|_d|_d|_d|_t��|_i|_	i|_
|�|��	|���dS#t$r/td|jr
|jdndz|j����wxYw)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�printrD)rKrMs  r'rIz
Stats.initvs��������
���
���
�����������������
�����������	��$�$�&�&�&�&�&���	�	�	��*�%)�Z�7�4�:�b�>�>�R�9�?C�{�
L�
L�
L�
L��	���s�)A?�?9B8c��|�	i|_dSt|t��r�t|d��5}t	j|��|_ddd��n#1swxYwY	t
j|��}tj	|j
��dz|z}n#YnxYw|g|_n7t|d��r'|�
��|j|_i|_|jstd|j�d|�����dS)N�rbz    �create_statszCannot create or construct a z
 object from )r\�
isinstancer�open�marshal�load�os�statr�ctime�st_mtimerU�hasattrrd�	TypeError�	__class__)rKrM�f�
file_statss    r'r^zStats.load_stats�sF���;��D�J��F�
��S�
!�
!�	��c�4���
-�A�$�\�!�_�_��
�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-����
-�
-�
-�
-�
��W�S�\�\�
��j��!4�5�5��>��D����
��������D�J�J�
�S�.�
)�
)�	���������D�J��C�I��z�	5��)�#�~�~�~�s�s�4�5�5�
5��s�A�A�A�#3B�Bc�x�|j���D]�\}\}}}}}|xj|z
c_|xj|z
c_|xj|z
c_d|vr|j�|��tt|����|j	kr!tt|����|_	��dS)N)�jprofiler�profiler)
r\�itemsrWrXr@r[rJrH�func_std_stringrY)rK�func�cc�nc�tt�ct�callerss       r'r_zStats.get_top_level_stats�s���/3�z�/?�/?�/A�/A�	?�	?�+�D�+�2�r�2�r�7�����"����O�O��"�O�O��M�M��"�M�M�*�g�5�5���"�"�4�(�(�(��?�4�(�(�)�)�D�,=�=�=�$'���(=�(=�$>�$>��!��	?�	?r(c�t�|s|St|��D�]"}t|��t|��krt|��}|xj|jz
c_|xj|jz
c_|xj|jz
c_|xj|jz
c_|jD]}|j�|���|j	|j	kr|j	|_	d|_
|j���D];\}}||jvr|j|}nddddif}t||��|j|<�<��$|S�Nr)�reversed�typerrUrWrXr@r[rJrYrVr\ru�add_func_stats)rK�arg_list�itemrwrj�
old_func_stats      r'rJz	Stats.add�sX���	��K��X�&�&�	G�	G�D��D�z�z�T�$�Z�Z�'�'��T�{�{���J�J�$�*�$�J�J����� 0�0����O�O�t��.�O�O��M�M�T�]�*�M�M���
)�
)����"�"�4�(�(�(�(�� �4�#4�4�4�$(�$5��!� �D�M�"�j�.�.�0�0�
G�
G�
��d��4�:�%�%�$(�J�t�$4�M�M�%&��1�a��$5�M�#1�-��#F�#F��
�4� � �
G��r(c��t|d��5}tj|j|��ddd��dS#1swxYwYdS)z:Write the profile data to a file we know how to load back.�wbN)rfrg�dumpr\)rKrrps   r'�
dump_statszStats.dump_stats�s���
�(�D�
!�
!�	(�Q��L���Q�'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�	(�	(s
�9�=�=)))rrPz
call count)))�rPzcumulative time))��rz	file name))��rzline number))��rz
function name))r�r�r�zname/file/line)))rrPzprimitive call count)))�rz
standard name)))�rPz
internal time)
r
rrrrrrrrrrrrc���|jsTix|_}i}|j���D]'\}}|}|r|sn||vrd||<n|||<|dd�}|��(|D]}||=�|jS)z)Expand all abbreviations that are unique.rNrP)r]�sort_arg_dict_defaultru)rK�dict�bad_list�word�tup�fragments      r'�get_sort_arg_defszStats.get_sort_arg_defs�s����!�	�(*�*�D����H�!�7�=�=�?�?�	
-�	
-�	��c����-�#����4�'�'�-.���*��%(�D��N�'����}�H��-��!�
�
����J�J��!�!r(c��|s	d|_|St|��dkr0t|dt��rddddd�|dg}nUt|��dkrB|dd�D]7}t	|��t	|d��krtd	����8|���}d
}d|_d}|D]P}t|t��r|j	}|||dz}|xj|||dzz
c_d}�Qg}|j
���D]9\}\}	}
}}}
|�|	|
||f|zt|��|fz���:|�tt!|��j���
��gx|_}|D]}|�|d���|S)Nrrrr
rr)rPrrr�r�zCan't have mixed argument typer5rQz, )�keyrP)rVrHrer>r�rnr��	sort_typer	r$r\ru�appendrv�sortr�	TupleComp�compare)rK�fieldrM�
sort_arg_defs�
sort_tuple�	connectorr��
stats_listrwrxryrzr{r|rV�tuples                r'�
sort_statszStats.sort_stats�s���	��D�M��K��u�:�:��?�?�z�%��(�C�8�8�?�$�"�!�'�)�)�*/�q��3�5�E�E���Z�Z�1�_�_��Q�R�R�y�
F�
F����9�9��U�1�X���.�.�#�$D�E�E�E�/��.�.�0�0�
��
�����	��	�	�D��$��(�(�
"��z��#�m�D�&9�!�&<�<�J��N�N�i�-��*=�a�*@�@�@�N�N��I�I��
�/3�z�/?�/?�/A�/A�	=�	=�+�D�+�2�r�2�r�7����r�2�r�2�.��5�.�t�4�4�d�;�<�
=�
=�
=�
=�	���J�y��'<�'<�'D�E�E��F�F�F�#%�%��
���	'�	'�E��O�O�E�"�I�&�&�&�&��r(c�F�|jr|j���|S�N)rV�reverse�rKs r'�
reverse_orderzStats.reverse_orders%���=�	$��M�!�!�#�#�#��r(c	�f�|j}ix|_}d}|���D]�\}\}}}}}	t|��}
tt	|
����|krtt	|
����}i}|	���D]\}}
|
|t|��<�|
|vrt||
|||||f��||
<��|||||f||
<��|j}t��x|_}|D]$}|�t|�����%||_	d|_
d|_|Sr~)r\ru�func_strip_pathrHrvr�r[rZrJrYrVrT)rK�oldstats�newstatsrYrwrxryrzr{r|�newfunc�
newcallers�func2�caller�old_top�new_tops                r'�
strip_dirszStats.strip_dirssj���:�� "�"��
�X���/7�~�~�/?�/?�
	A�
	A�+�D�+�2�r�2�r�7�%�d�+�+�G��?�7�+�+�,�,�|�;�;�"�?�7�#;�#;�<�<���J�!(�����
<�
<�
��v�5;�
�?�5�1�1�2�2��(�"�"�$2�(0��(9�)+�R��R��(D�%F�%F���!�!�&(��R��Z�$@���!�!��.��#&�5�5�(�����	/�	/�D��K�K���-�-�.�.�.�.�(�����
�����r(c���|jrdSix|_}|j���D]B\}\}}}}}||vri||<|���D]\}}	||vri||<|	|||<��CdSr�)rTr\ru)
rKrTrwrxryrzr{r|r�r�s
          r'�calc_calleeszStats.calc_callees6s�����	��F�)+�+���;�/3�z�/?�/?�/A�/A�	3�	3�+�D�+�2�r�2�r�7��;�&�&�$&��D�!�!(�����
3�
3�
��v���+�+�)+�K��&�,2��E�"�4�(�(�
3�	�r(c��|}t|t��rv	tj|��}n!#tj$r|d|zz
}||fcYSwxYwg}|D]9}|�t
|����r|�|���:n�t|��}t|t��r0d|cxkrdkr#nn t||zdz��}|d|�}n1t|t��rd|cxkr|krnn|}|d|�}t|��t|��kr)|dt|���dt|���d|�d	�z
}||fS)
Nz#   <Invalid regular expression %r>
gg�?g�?rz   List reduced from z to z due to restriction <z>
)rer�re�compile�error�searchrvr�rHr=r>)rK�sel�list�msg�new_list�rexrw�counts        r'�eval_print_amountzStats.eval_print_amountIs������c�3���	(�
%��j��o�o�����8�
%�
%�
%��=��C�C����}�$�$�$�
%�����H��
*�
*���:�:�o�d�3�3�4�4�*��O�O�D�)�)�)��
*���I�I�E��#�u�%�%�
(�#��*:�*:�*:�*:�s�*:�*:�*:�*:�*:��E�C�K�"�,�-�-������<����C��%�%�
(�!�s�*:�*:�*:�*:�U�*:�*:�*:�*:�*:�������<���t�9�9��H�
�
�%�%��C��D�	�	�	�	�3�x�=�=�=�=�#�#�#�/�
/�C���}�s�.�A�Ac
���|jr|jdd�n%t|j�����}|st	di��Stt
|j����}i}t	||��}|D]�}|j|\}}}}	}
|\}}}
||krt|��n!t|��dzt|��z}tt
|����}|dkrdntt
||z����}tt
|	����}|dkrdntt
|	|z����}t|||||||��}|||
<��|S)a?This method returns an instance of StatsProfile, which contains a mapping
        of function names to instances of FunctionProfile. Each FunctionProfile
        instance holds information related to the function's profile such as how
        long the function took to run, how many times it was called, etc...
        Nr�/rP)
rVr�r\�keysrr=�f8r@rr
)rK�	func_listr@rA�
stats_profilerwrxryrzr{r|r:r;�	func_namerrr8rr9�func_profiles                    r'�get_stats_profilezStats.get_stats_profilecsv��)-�
�R�D�M�!�!�!�$�$�4��
���@Q�@Q�;R�;R�	��	'���2�&�&�&���D�M�*�*�+�+���
�$�X�}�=�=�
��	4�	4�D�&*�j��&6�#�B��B��G�04�-�I�{�I� "�b���S��W�W�W�s�2�w�w��}�s�2�w�w�/F�F��B�r�F�F�m�m�G�$&�!�G�G�b�b��r�"�R�%�y�y�1A�1A�O��B�r�F�F�m�m�G�$&�!�G�G�b�b��r�"�R�%�y�y�1A�1A�O�*����������L�(4�M�)�$�$��r(c��|j}|jr|jdd�}d|jzdz}n(t|j�����}d}|D]}|�|||��\}}�t|��}|sd|fSt||j	���|t|j��krCd}|D]>}tt|����|krtt|����}�?|dz|fS)Nz   Ordered by: �
z!   Random listing order was used
rrRr�)rYrVr�r�r\r�r�rHrarDrv)rK�sel_list�width�	stat_listr��	selectionr�rws        r'�get_print_listzStats.get_print_list�s���!���=�	7��
�a�a�a�(�I�#�d�n�4�t�;�C�C��T�Z�_�_�.�.�/�/�I�6�C�!�	O�	O�I�!�3�3�I�y�#�N�N�N�I�s�s��I�����	 ��i�<��
�c���$�$�$�$��3�t�z�?�?�"�"��E�!�
7�
7�����-�-�.�.��6�6���� 5� 5�6�6�E���Q�w�	�!�!r(c���|jD]}t||j����|jrt|j���d}|jD]&}t|t	|��|j����'t||jdd|j���|j|jkrtd|jzd|j���td|jz|j���t|j���|�|��\}}|rX|�	��|D]}|�
|���t|j���t|j���|S)NrR�        zfunction calls� ��endrSz(%d primitive calls)zin %.3f seconds)rUrarDr[�func_get_function_namerWrXr@r��print_title�
print_line)rK�amountr�indentrwr�r�s       r'�print_statszStats.print_stats�s����
�	.�	.�H��(���-�-�-�-�-��:�	$��t�{�#�#�#�#����N�	J�	J�D��&�0��6�6�T�[�I�I�I�I�I�
�f�d�&�(8�c���T�T�T�T���t��.�.��(�4�?�:��$�+�V�V�V�V�
��$�-�/�d�k�B�B�B�B�
�4�;������)�)�&�1�1���t��	$��������
&�
&������%�%�%�%��t�{�#�#�#�#��t�{�#�#�#�#��r(c�r�|�|��\}}|r�|���|�|d��|D]E}||jvr#|�|||j|���.|�||i���Ft|j���t|j���|S)Nz	called...rR)r�r��print_call_headingrT�print_call_linerarD)rKr�r�r�rws     r'�
print_calleeszStats.print_callees�s����)�)�&�1�1���t��
	$��������#�#�E�;�7�7�7��
:�
:���4�+�+�+��(�(���d�6F�t�6L�M�M�M�M��(�(���b�9�9�9�9��t�{�#�#�#�#��t�{�#�#�#�#��r(c��|�|��\}}|rp|�|d��|D]-}|j|\}}}}}	|�|||	d���.t	|j���t	|j���|S)Nzwas called by...z<-rR)r�r�r\r�rarD)
rKr�r�r�rwrxryrzr{r|s
          r'�
print_callerszStats.print_callers�s����)�)�&�1�1���t��	$��#�#�E�+=�>�>�>��
A�
A��*.�*�T�*:�'��B��B���$�$�U�D�'�4�@�@�@�@��t�{�#�#�#�#��t�{�#�#�#�#��r(c�t�td�|��|z|j���d}|j���D]O\}}}}}|rEtt
|�������}	t|	t��}n�P|rtd|zdz|j���dSdS)Nz	Function rRFr�z    ncalls  tottime  cumtime)	ra�ljustrDr\r#�next�iterrer�)
rK�	name_size�column_title�	subheaderrxryrzr{r|r$s
          r'r�zStats.print_call_heading�s���
�k���	�*�*�\�9���L�L�L�L��	�'+�z�'8�'8�':�':�	�	�#�B��B��G��
��T�'�.�.�"2�"2�3�3�4�4��&�u�e�4�4�	���
��	T��#�i�-�"@�@�t�{�S�S�S�S�S�S�	T�	Tr(�->c	���tt|���|��|zd|j���|st|j���dSt	|�����}d}|D]�}t|��}||}	t
|	t��rn|	\}
}}}
|
|krd|
|fz}nd|
fz}|�ddt|��zz���dt|���dt|
���d	|��}|d
z}n-|�d|	�dt|j|d
����}|d
z}t||z|z|j���d}��dS)Nr�r�rRrQz%d/%dz%dr�r�z  r�(z) r�)rarvr�rD�sortedr�rer��rjustrHr�r\)rKr��source�	call_dict�arrow�clistr�rwrr$ryrxrzr{�substats�
left_widths                r'r�zStats.print_call_line�s���
�o�f�%�%�+�+�I�6�6��>�C�d�k�Z�Z�Z�Z��	��t�{�#�#�#�#��F��y�~�~�'�'�(�(�����	�	�D�"�4�(�(�D��d�O�E��%��'�'�
+�!&���B��B���8�8�&�"�b��1�H�H�#�r�e�|�H�-5�^�^�A�a��F���m�O�-L�-L�-L�-L�-/��V�V�V�V�R��V�V�V�V�T�T�C��&��]�
�
�*.�$�$����r�$�*�T�:J�1�:M�7N�7N�7N�O��&��]�
��&��#�h�.�T�[�A�A�A�A��F�F�!	�	r(c�`�tdd|j���td|j���dS)Nz-   ncalls  tottime  percall  cumtime  percallr�r�zfilename:lineno(function)rR�rarDr�s r'r�zStats.print_title�s6��
�=�3�T�[�Y�Y�Y�Y�
�)���<�<�<�<�<�<r(c��|j|\}}}}}t|��}||kr|dzt|��z}t|�d��d|j���tt|��d|j���|dkrtdd|j���n'tt||z��d|j���tt|��d|j���|dkrtdd|j���n'tt||z��d|j���tt
|��|j���dS)Nr��	r�r�rr�rR)r\rrar�rDr�rv)rKrwrxryrzr{r|�cs        r'r�zStats.print_line�sG��"&�*�T�"2���B��B����G�G��
��8�8��C��#�b�'�'�!�A�
�a�g�g�a�j�j�c���4�4�4�4�
�b��f�f�#�D�K�0�0�0�0�
��7�7��%�S�t�{�3�3�3�3�3��"�R��U�)�)��4�;�7�7�7�7�
�b��f�f�#�D�K�0�0�0�0�
��7�7��%�S�t�{�3�3�3�3�3��"�R��U�)�)��4�;�7�7�7�7�
�o�d�#�#�$�+�6�6�6�6�6�6r()r�)r)r*r+rBrNrIr^r_rJr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r5r(r'rrJs���������B&*���������&���,?�?�?����4(�(�(�D�C�H�H�B�D�B�F�G�M�F�F�F���� "�"�"�&%�%�%�N���
���:���&���4!�!�!�F"�"�"�0���.
�
�
�	�	�	�
T�
T�
T�����2=�=�=�7�7�7�7�7r(rc��eZdZdZd�Zd�ZdS)r�a�This class provides a generic function for comparing any two tuples.
    Each instance records a list of tuple-indices (from most significant
    to least significant), and sort direction (ascending or descending) for
    each tuple-index.  The compare functions can then be used as the function
    argument to the system sort() function when a list of tuples need to be
    sorted in the instances order.c��||_dSr���comp_select_list)rKrs  r'rNzTupleComp.__init__s�� 0����r(c�j�|jD]*\}}||}||}||kr|cS||kr|cS�+dSr~r)rK�left�right�index�	direction�l�rs       r'r�zTupleComp.comparesa�� $� 5�	!�	!��E�9��U��A��e��A��1�u�u�!�z�!�!�!��1�u�u� � � � ���qr(N)r)r*r+rBrNr�r5r(r'r�r�
s<������&�&�1�1�1�����r(r�c�R�|\}}}tj�|��||fSr�)ri�path�basename)r�rrrs    r'r�r�#s+��$��H�d�D�
�7���H�%�%�t�T�1�1r(c��|dS)Nr�r5)rws r'r�r�'s����7�Nr(c��|dd�dkrA|d}|�d��r"|�d��r
d|dd�zS|Sd|zS)	Nr�)�~r�<�>z{%s}rrPz	%s:%d(%s))�
startswith�endswith)r�rs  r'rvrv*sh����!��}�� � ���|���?�?�3���	�D�M�M�#�$6�$6�	��D��2��J�&�&��K��Y�&�&r(c�d�|\}}}}}|\}}}	}
}||z||z||	z||
zt||��fS)z3Add together all the stats for two profile entries.)�add_callers)�targetr�rxryrzr{r|�t_cc�t_nc�t_tt�t_ct�	t_callerss            r'r�r�;sR��$��B��B��G�(.�%�D�$��d�I��t�G�R��W�b��g�r�$�w��)�W�-�-�/�/r(c	�<�i}|���D]
\}}|||<�|���D]e\}}||vrWt|t��r1td�t|||��D����||<�O||xx|z
cc<�`|||<�f|S)z*Combine two caller lists in a single list.c3�&K�|]\}}||zV��
dSr�r5)�.0�i�js   r'�	<genexpr>zadd_callers.<locals>.<genexpr>Ks*����)[�)[�D�A�q�!�a�%�)[�)[�)[�)[�)[�)[r()rurer��zip)rr��new_callersrwr�s     r'rrBs����K������#�#���f�"��D��������	'�	'���f��;����&�%�(�(�
,�$)�)[�)[�C���TX�HY�<Z�<Z�)[�)[�)[�$[�$[��D�!�!��D�!�!�!�V�+�!�!�!�!� &�K�����r(c�B�d}|���D]}||z
}�|S)z@Sum the caller statistics to get total number of calls received.r)r#)r|ryr
s   r'�count_callsr$Ss0��	
�B����!�!����
�e����
�Ir(c��d|zS)Nz%8.3fr5)�xs r'r�r�^s���Q�;�r(�__main__c��eZdZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS)�ProfileBrowserNc��tj�|��d|_d|_t
j|_|�|�|��dSdS)N�% )	�cmd�CmdrN�promptr\rFrGrD�do_read)rK�profiles  r'rNzProfileBrowser.__init__msU���G���T�"�"�"��D�K��D�J��*�D�K��"����W�%�%�%�%�%�#�"r(c���|���}g}|D]�}	|�t|�����&#t$rYnwxYw	t	|��}|dks|dkrtd|j����i|�|���#t$rYnwxYw|�|����|jrt|j|��|�ntd|j���dS)Nrrz#Fraction argument must be in [0, 1]rR�No statistics object is loaded.)	�splitr�r>�
ValueErrorr=rarDr\�getattr)rK�fnrrL�	processed�term�fracs       r'�genericzProfileBrowser.genericus/���:�:�<�<�D��I��
'�
'����$�$�S��Y�Y�/�/�/���!�����D������ ��;�;�D��a�x�x�4�!�8�8��C�$�+�V�V�V�V� ��$�$�T�*�*�*���!�����D������ � ��&�&�&�&��z�
K�'���
�B�'�'��3�3�3��7�d�k�J�J�J�J��1s'�"?�
A�A�1B�B�
B%�$B%c��td|j���td|j���td|j���td|j���td|j���td|j���dS)NzArguments may be:rRz0* 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�s r'�generic_helpzProfileBrowser.generic_help�s����%�D�K�8�8�8�8��D�4�;�W�W�W�W��N�UY�U`�a�a�a�a��A���T�T�T�T��L�SW�S^�_�_�_�_��0�t�{�C�C�C�C�C�Cr(c���|jrO	|j�|��nI#t$r&}td|�d|��|j���Yd}~nd}~wwxYwtd|j���dS)NzFailed to load statistics for z: rRr2r)r\rJ�OSErrorrarD)rKr�es   r'�do_addzProfileBrowser.do_add�s����z�
K�`��J�N�N�4�(�(�(�(���`�`�`��E�D�D�D�!�!�L�SW�S^�_�_�_�_�_�_�_�_�_�����`�����7�d�k�J�J�J�J��1s�$�
A�A�Ac�2�td|j���dS)Nz>Add profile info from given file to current statistics object.rRr�r�s r'�help_addzProfileBrowser.help_add�s ���R�Y]�Yd�e�e�e�e�e�er(c�.�|�d|��S)Nr��r:�rKrs  r'�
do_calleeszProfileBrowser.do_callees�����<�<���6�6�6r(c�Z�td|j���|���dS)Nz6Print callees statistics from the current stat object.rR�rarDr<r�s r'�help_calleeszProfileBrowser.help_callees��2���J�QU�Q\�]�]�]�]��������r(c�.�|�d|��S)Nr�rDrEs  r'�
do_callerszProfileBrowser.do_callers�rGr(c�Z�td|j���|���dS)Nz6Print callers statistics from the current stat object.rRrIr�s r'�help_callerszProfileBrowser.help_callers�rKr(c�2�td|j���dS)NrQrRrr�rEs  r'�do_EOFzProfileBrowser.do_EOF�s���"�4�;�'�'�'�'��1r(c�2�td|j���dS�NzLeave the profile browser.rRr�r�s r'�help_EOFzProfileBrowser.help_EOF�����.�T�[�A�A�A�A�A�Ar(c��dS)Nrr5rEs  r'�do_quitzProfileBrowser.do_quit�s���1r(c�2�td|j���dSrSr�r�s r'�	help_quitzProfileBrowser.help_quit�rUr(c���|r�	t|��|_np#t$r,}t|jd|j���Yd}~dSd}~wt$r/}t|jjdz||j���Yd}~dSd}~wwxYw|dz|_	nSt|j	��dkr%|j	dd�}|�|��ntd|j���dS)	NrrR�:r+r����z1No statistics object is current -- cannot reload.r)rr\r>rarLrDr`ror)r.rHr/)rKr�errs   r'r/zProfileBrowser.do_read�s���
]��!&�t���D�J�J�������#�(�1�+�D�K�8�8�8�8��F�F�F�F�F����� �����#�-�0�3�6��$�+�N�N�N�N��F�F�F�F�F���������#�T�k�����T�[�!�!�A�%�%��{�3�B�3�'�����T�"�"�"�"��I�PT�P[�\�\�\�\��1s ��
B�!A
�

B�$B�Bc�^�td|j���td|j���dS)Nz+Read in profile data from a specified file.rRz*Without argument, reload the current file.r�r�s r'�	help_readzProfileBrowser.help_read�s4���?�d�k�R�R�R�R��>�T�[�Q�Q�Q�Q�Q�Qr(c�t�|jr|j���ntd|j���dS)Nr2rRr)r\r�rarDrEs  r'�
do_reversezProfileBrowser.do_reverse�s?���z�
K��
�(�(�*�*�*�*��7�d�k�J�J�J�J��1r(c�2�td|j���dS)Nz/Reverse the sort order of the profiling report.rRr�r�s r'�help_reversezProfileBrowser.help_reverse�s���C�$�+�V�V�V�V�V�Vr(c����|jstd|j���dS|j����|rOt	�fd�|���D����r"|jj|����n[td|j���tj�	��D]&\}}t|�d|d��|j����'dS)Nr2rRc3� �K�|]}|�vV��	dSr�r5)rr&�abbrevss  �r'r z)ProfileBrowser.do_sort.<locals>.<genexpr>�s'�����A�A�q�Q�'�\�A�A�A�A�A�Ar(z/Valid sort keys (unique prefixes are accepted):z -- rr)
r\rarDr��allr3r�rr�ru)rKrr�r$rfs    @r'�do_sortzProfileBrowser.do_sort�s�����:�
��7�d�k�J�J�J�J����j�2�2�4�4�G��
J��A�A�A�A�D�J�J�L�L�A�A�A�A�A�
J�%��
�%�t�z�z�|�|�4�4�4��G�d�k�Z�Z�Z�Z�$)�$?�$E�$E�$G�$G�J�J�L�S�%�����U�1�X�X�6�T�[�I�I�I�I�I��1r(c�^�td|j���td|j���dS)Nz.Sort profile data according to specified keys.rRz3(Typing `sort' without arguments lists valid keys.)r�r�s r'�	help_sortzProfileBrowser.help_sort�s4���B���U�U�U�U��G�d�k�Z�Z�Z�Z�Z�Zr(c�4���fd�tjD��S)Nc�>��g|]}|�����|��Sr5)r)r�a�texts  �r'�
<listcomp>z0ProfileBrowser.complete_sort.<locals>.<listcomp>�s*���Q�Q�Q�!�a�l�l�4�>P�>P�Q�A�Q�Q�Qr()rr�)rKrnrLs ` r'�
complete_sortzProfileBrowser.complete_sort�s ���Q�Q�Q�Q�u�:�Q�Q�Q�Qr(c�.�|�d|��S)Nr�rDrEs  r'�do_statszProfileBrowser.do_stats�s���<�<�
�t�4�4�4r(c�Z�td|j���|���dS)Nz.Print statistics from the current stat object.rRrIr�s r'�
help_statszProfileBrowser.help_stats�s0���B���U�U�U�U��������r(c�v�|jr|j���dStd|j���dS)Nr2rR)r\r�rarDrEs  r'�do_stripzProfileBrowser.do_strip�sC���z�
K��
�%�%�'�'�'�'�'��7�d�k�J�J�J�J�J�Jr(c�2�td|j���dS)Nz<Strip leading path information from filenames in the report.rRr�r�s r'�
help_stripzProfileBrowser.help_strip�s ���P�W[�Wb�c�c�c�c�c�cr(c�2�td|j���dS)NzShow help for a given command.rRr�r�s r'�	help_helpzProfileBrowser.help_help�s���2���E�E�E�E�E�Er(c��|r|SdSr�r5)rK�stoprs   r'�postcmdzProfileBrowser.postcmd�s���
����4r(r�)r)r*r+rNr:r<r@rBrFrJrMrOrQrTrWrYr/r_rarcrhrjrprrrtrvrxrzr}r5r(r'r)r)ls�������	&�	&�	&�	&�	�	�	�0	D�	D�	D�	�	�	�	f�	f�	f�	7�	7�	7�	 �	 �	 �	7�	7�	7�	 �	 �	 �	�	�	�	B�	B�	B�	�	�	�	B�	B�	B�	�	�	�"	R�	R�	R�	�	�	�	W�	W�	W�	�	�	�	[�	[�	[�	R�	R�	R�	5�	5�	5�	 �	 �	 �	K�	K�	K�
	d�	d�	d�	F�	F�	F�	�	�	�	�	r(r)rr�z*Welcome to the profile statistics browser.rRzGoodbye.),rBrFrirrgr��enumrr�	functoolsr�dataclassesr�typingr�__all__r	r
rrr�r�r�rvr�rr$r�r)r,�readline�ImportErrorr-r)rH�argv�initprofile�browserr0r@rarD�cmdloop�KeyboardInterruptr5r(r'�<module>r�sl��9�9�,�
�
�
�	�	�	�	���������	�	�	�	�&�&�&�&�&�&�&�&� � � � � � �!�!�!�!�!�!�������
A�
A�
A��
��g�������������*��t����������������t����.�.�.�.�.�.�.���.�
~7�~7�~7�~7�~7�~7�~7�~7�@��������22�2�2����	'�	'�	'�"/�/�/����"�������z����J�J�J�
��������
�
�
���
����P�P�P�P�P���P�P�P�d�s�3�8�}�}�q����h�q�k�����
� �.��-�-���x����|�	$�	$�G��N�N�7�#�#�#�#�
��:���P�P�P�P�������
��j�w�~�.�.�.�.�.�.���
�
�
����
����I�s%�C�C�C�A*E?�?F�F

Zerion Mini Shell 1.0