Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/test_profile.cpython-311.opt-1.pyc
�

�Ke�"���dZddlZddlZddlZddlZddlmZddlmZddl	m
Z
mZmZm
Z
ddlmZddlZddlmZmZddlmZmZGd	�d
ej��Zd�Zed���Zd
�ZiZded<ded<ded<edkre��dSdS)z"Test suite for the profile module.�N)�unified_diff)�StringIO)�TESTFN�unlink�temp_dir�
change_cwd)�contextmanager)�testfunc�timer)�assert_python_failure�assert_python_okc�r�eZdZejZeZgd�ZdZd�Z	d�Z
ed���Zd�Z
d�Zd�Zd	�Zd
�Zd�ZdS)
�ProfileTest)�print_stats�
print_callers�
print_calleesz:0(max)c�.�tt��dS�N)rr��selfs �;/usr/local/apps/python3/lib/python3.11/test/test_profile.py�tearDownzProfileTest.tearDowns���v������c��tSr)�_ProfileOutputrs r�get_expected_outputzProfileTest.get_expected_outputs���rc����g}|�td��}t��}|�dt��t	����|�t��|z
��|jD]�}t��}tj	||���}|�
���d��t||����|�
�����}tj�dd��d��fd�|D��}|�d�|������|S)	N���MbP?�
testfunc()��stream�stdname�.�c�@��g|]}�|v�|�����S�)�rstrip)�.0�line�mod_names  �r�
<listcomp>z,ProfileTest.do_profiling.<locals>.<listcomp>/s+���K�K�K��(�d�:J�:J�d�k�k�m�m�:J�:J�:Jr�
)�
profilerclassr�runctx�globals�locals�append�methodnamesr�pstats�Stats�
strip_dirs�
sort_stats�getattr�getvalue�
splitlinesr
�
__module__�rsplit�join)	�cls�results�prof�start_timer�
methodname�s�stats�outputr*s	        @r�do_profilingzProfileTest.do_profilings=������ � ���.�.���g�g�����L�'�)�)�V�X�X�6�6�6����u�w�w��,�-�-�-��/�	.�	.�J��
�
�A��L��a�0�0�0�E������)�)�)�4�4�4�&�G�E�:�&�&�(�(�(��Z�Z�\�\�,�,�.�.�F��*�1�1�#�q�9�9�!�<�H�L�K�K�K��K�K�K�F��N�N�4�9�9�V�,�,�-�-�-�-��rc	�2�|���}|���}|�|dd��g}t|j��D]�\}}||}||dz}||krq|�d|�d|jj�d���|�t|�
d��|�
d��d�	������|r*|�d�|����dSdS)
Nri�r$z
Stats.z output for z does not fit expectation:r,�)�lineterm)
rEr�assertEqual�	enumerater2r1r-�__name__�extendr�split�failr<)rr>�expectedrN�i�method�a�bs        r�
test_cprofilezProfileTest.test_cprofile3s9���#�#�%�%���+�+�-�-��������T�*�*�*���"�4�#3�4�4�	*�	*�I�A�v��� �A���!���A��A�v�v����9�v�9�9�#�1�:�9�9�9�:�:�:����L�����������
�
�%'�)�)�)�*�*�*���	'��I�I�d�i�i��o�o�&�&�&�&�&�	'�	'rc	��gd�}|D]�}t��}|�td��}|�|t	��t����t
j||���}|���|�	��}|�
|j|d�||������dS)N)zmax([0])zmax([0], key=int)zmax([0], **dict(key=int))zmax(*([0],))zmax(*([0],), key=int)zmax(*([0],), **dict(key=int))rr z&Profiling {0!r} didn't report max:
{1})
rr-rr.r/r0r3r4rr8�assertIn�expected_max_output�format)r�stmts�stmtrBr?rC�ress       r�test_calling_conventionsz$ProfileTest.test_calling_conventionsDs���
�
�
���	M�	M�D��
�
�A��%�%�e�U�3�3�D��K�K��g�i�i����2�2�2��L��a�0�0�0�E��������*�*�,�,�C��M�M�$�2�C�9�@�@��s�K�K�
M�
M�
M�
M�	M�	Mrc�6�t��5|j�d��ddd��n#1swxYwY|j�dt���|�t
j�t����dS)Nzint('1')��filename)�silent�profilermodule�runr�
assertTrue�os�path�existsrs r�test_runzProfileTest.test_runYs���
�X�X�	0�	0���#�#�J�/�/�/�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0�	0����	0�	0�	0�	0�����
�V��<�<�<��������v�.�.�/�/�/�/�/s�6�:�:c��t��5|j�dt��t	����ddd��n#1swxYwY|j�dt��t	��t
���|�tj�	t
����dS)Nrr^)
r`rar.r/r0rrcrdrerfrs r�test_runctxzProfileTest.test_runctx_s���
�X�X�	J�	J���&�&�|�W�Y�Y����I�I�I�	J�	J�	J�	J�	J�	J�	J�	J�	J�	J�	J����	J�	J�	J�	J���"�"�<����F�H�H�+1�	#�	3�	3�	3��������v�.�.�/�/�/�/�/s�5A�A�Ac��td|jjd��td|jjdd��td|jjdddd��dS)N�-m�random_module_xyz�timeitz-n�1)rrarKr
rs r�test_run_profile_as_modulez&ProfileTest.test_run_profile_as_modulefso���d�D�$7�$@�$�G�G�G�	�d�D�$7�$@�"�$7�	9�	9�	9�	��t�2�;��x��s�	4�	4�	4�	4�	4rc	���t��5}t|��5tjd��t	ddd���5}|�d��ddd��n#1swxYwYt
d|jjdd	d��|�	tj
�d	����ddd��n#1swxYwYddd��dS#1swxYwYdS)
N�destzdemo.py�wzutf-8)�encodingzimport os; os.chdir("dest")rkz-oz
out.pstats)rrrd�mkdir�open�writer
rarKrcrerf)r�tmpdir�fs   r�(test_output_file_when_changing_directoryz4ProfileTest.test_output_file_when_changing_directoryrs���
�Z�Z�	:�6�:�f�#5�#5�	:�	:��H�V�����i��w�7�7�7�
7�1����5�6�6�6�
7�
7�
7�
7�
7�
7�
7�
7�
7�
7�
7����
7�
7�
7�
7�
��d�)�2��l��
�
�
�
�O�O�B�G�N�N�<�8�8�9�9�9�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:����	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:����	:�	:�	:�	:�	:�	:sY�C&�'C�A(�C�(A,�,C�/A,�0AC�C&�C	�C&�C	�C&�&C*�-C*N)rKr:�__qualname__�profile�Profiler-rar2rWrr�classmethodrErTr\rgriroryr&rrrrs��������O�M��N�C�C�C�K�#������������[��('�'�'�"M�M�M�*0�0�0�0�0�0�
4�
4�
4�:�:�:�:�:rrc
��|�d��}td|z��|���}g}t|d��5}|D].}|�|��|�d��rn�/ddd��n#1swxYwYt|d��5}|�|��|�d��t|j	��D]*\}}|�d|�d||d	z�d
����+|�d��ddd��dS#1swxYwYdS)N�cozRegenerating %s...�rz#--cutrrz_ProfileOutput = {}
z_ProfileOutput[z	] = """\
r$z"""
z'
if __name__ == "__main__":
    main()
)
r'�printrErur1�
startswith�
writelinesrvrJr2)r_r=r>�newfilerxr)rPrQs        r�regenerate_expected_outputr��s������t�$�$�H�	�
��
)�*�*�*���� � �G��G�	
�h��	�	����	�	�D��N�N�4� � � ����x�(�(�
���
�������������������
�h��	�	�>��	���W����	���'�(�(�(�"�3�?�3�3�	+�	+�I�A�v�
�G�G�G��F�F�G�A�a�C�L�L�L�*�
+�
+�
+�
+�	���<�=�=�=�
>�>�>�>�>�>�>�>�>�>�>�>����>�>�>�>�>�>s%�2B�B�B�'A?D3�3D7�:D7c#�K�tj}	t��t_dV�|t_dS#|t_wxYwr)�sys�stdoutr)r�s rr`r`�sD����
�Z�F���Z�Z��
�
������
�
�
��V��
����s	�:�Ac��dtjvrtj��dSt	t
t��dS)Nz-r)r��argv�unittest�mainr��__file__rr&rrr�r��s4���3�8����
������"�8�[�9�9�9�9�9ra�       28   27.972    0.999   27.972    0.999 profilee.py:110(__getattr__)
        1  269.996  269.996  999.769  999.769 profilee.py:25(testfunc)
     23/3  149.937    6.519  169.917   56.639 profilee.py:35(factorial)
       20   19.980    0.999   19.980    0.999 profilee.py:48(mul)
        2   39.986   19.993  599.830  299.915 profilee.py:55(helper)
        4  115.984   28.996  119.964   29.991 profilee.py:73(helper1)
        2   -0.006   -0.003  139.946   69.973 profilee.py:84(helper2_indirect)
        8  311.976   38.997  399.912   49.989 profilee.py:88(helper2)
        8   63.976    7.997   79.960    9.995 profilee.py:98(subhelper)ra�:0(append)                        <- profilee.py:73(helper1)(4)  119.964
:0(exc_info)                      <- profilee.py:73(helper1)(4)  119.964
:0(hasattr)                       <- profilee.py:73(helper1)(4)  119.964
                                     profilee.py:88(helper2)(8)  399.912
profilee.py:110(__getattr__)      <- :0(hasattr)(12)   11.964
                                     profilee.py:98(subhelper)(16)   79.960
profilee.py:25(testfunc)          <- <string>:1(<module>)(1)  999.767
profilee.py:35(factorial)         <- profilee.py:25(testfunc)(1)  999.769
                                     profilee.py:35(factorial)(20)  169.917
                                     profilee.py:84(helper2_indirect)(2)  139.946
profilee.py:48(mul)               <- profilee.py:35(factorial)(20)  169.917
profilee.py:55(helper)            <- profilee.py:25(testfunc)(2)  999.769
profilee.py:73(helper1)           <- profilee.py:55(helper)(4)  599.830
profilee.py:84(helper2_indirect)  <- profilee.py:55(helper)(2)  599.830
profilee.py:88(helper2)           <- profilee.py:55(helper)(6)  599.830
                                     profilee.py:84(helper2_indirect)(2)  139.946
profilee.py:98(subhelper)         <- profilee.py:88(helper2)(8)  399.912ra�:0(hasattr)                       -> profilee.py:110(__getattr__)(12)   27.972
<string>:1(<module>)              -> profilee.py:25(testfunc)(1)  999.769
profilee.py:110(__getattr__)      ->
profilee.py:25(testfunc)          -> profilee.py:35(factorial)(1)  169.917
                                     profilee.py:55(helper)(2)  599.830
profilee.py:35(factorial)         -> profilee.py:35(factorial)(20)  169.917
                                     profilee.py:48(mul)(20)   19.980
profilee.py:48(mul)               ->
profilee.py:55(helper)            -> profilee.py:73(helper1)(4)  119.964
                                     profilee.py:84(helper2_indirect)(2)  139.946
                                     profilee.py:88(helper2)(6)  399.912
profilee.py:73(helper1)           -> :0(append)(4)   -0.004
profilee.py:84(helper2_indirect)  -> profilee.py:35(factorial)(2)  169.917
                                     profilee.py:88(helper2)(2)  399.912
profilee.py:88(helper2)           -> :0(hasattr)(8)   11.964
                                     profilee.py:98(subhelper)(8)   79.960
profilee.py:98(subhelper)         -> profilee.py:110(__getattr__)(16)   27.972r�__main__)�__doc__r�r3r�rd�difflibr�ior�test.support.os_helperrrrr�
contextlibr	r{�
test.profileer
r�test.support.script_helperrr
�TestCaserr�r`r�rrKr&rr�<module>r�s���(�(�
�
�
�
�
�
�
�
�����	�	�	�	� � � � � � �������G�G�G�G�G�G�G�G�G�G�G�G�%�%�%�%�%�%�����)�)�)�)�)�)�)�)�N�N�N�N�N�N�N�N�m:�m:�m:�m:�m:�(�#�m:�m:�m:�`>�>�>�(������:�:�:���	!K��}��#L����$#R����&�z����D�F�F�F�F�F��r