Sindbad~EG File Manager
�
'Μg�"���dZddlZddlZddlZddlZddlmZddlmZddl m
Z
mZmZm
Z
ddlmZddlZddlmZmZddlmZmZGd �d
ej.�Zd�Zed��Zd
�ZiZded<ded<ded<edk(re�yy)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�t�eZdZejZeZgd�ZdZd�Z d�Z
ed��Zd�Z
d�Zd�Zd �Zd
�Zd�Zy)
�ProfileTest)�print_stats�
print_callers�
print_calleesz:0(max)c�"�tt�y�N)rr��selfs �./usr/local/lib/python3.12/test/test_profile.py�tearDownzProfileTest.tearDowns ���v��c��tSr)�_ProfileOutputrs r�get_expected_outputzProfileTest.get_expected_outputs���rc��g}|jtd�}t�}|jdt�t ��|jt�|z
�|jD]�}t�}tj||��}|j�jd�t||��|j�j�}tj j#dd�d}|D� cgc]} || vs�| j%���}} |jdj'|����|Scc} w)N���MbP?�
testfunc()��stream�stdname�.��
)�
profilerclassr�runctx�globals�locals�append�methodnamesr�pstats�Stats�
strip_dirs�
sort_stats�getattr�getvalue�
splitlinesr
�
__module__�rsplit�rstrip�join)
�cls�results�prof�start_timer�
methodname�s�stats�output�mod_name�lines
r�do_profilingzProfileTest.do_profilings����� � ���.���g�����L�'�)�V�X�6����u�w��,�-��/�/�J��
�A��L�L��a�0�E�����)�)�)�4�&�G�E�:�&�(��Z�Z�\�,�,�.�F��*�*�1�1�#�q�9�!�<�H�17�K���(�d�:J�d�k�k�m��F�K��N�N�4�9�9�V�,�-�*����Ls� E �E c ���|j�}|j�}|j|dd�g}t|j�D]\}}||}||dz}||k7s�|jd|�d|jj�d��|jt|jd�|jd�d� ����|r!|jdj|��yy)
Nri�r$z
Stats.z output for z does not fit expectation:r%�)�lineterm)
rAr�assertEqual� enumerater+r*r&�__name__�extendr�split�failr6)rr8�expectedrJ�i�method�a�bs r�
test_cprofilezProfileTest.test_cprofile3s����#�#�%���+�+�-��������T�*���"�4�#3�#3�4�I�A�v��� �A���!���A��A�v����h�v�h�l�#�1�1�:�:�;�<9�9�:����L����������
�%'�)�*�5���I�I�d�i�i��o�&�rc �h�gd�}|D]�}t�}|jtd�}|j|t �t��t
j||��}|j�|j�}|j|j|dj||����y)N)zmax([0])zmax([0], key=int)zmax([0], **dict(key=int))zmax(*([0],))zmax(*([0],), key=int)zmax(*([0],), **dict(key=int))rr z&Profiling {0!r} didn't report max:
{1})
rr&rr'r(r)r,r-rr1�assertIn�expected_max_output�format)r�stmts�stmtr<r9r=�ress r�test_calling_conventionsz$ProfileTest.test_calling_conventionsDs���
���D��
�A��%�%�e�U�3�D��K�K��g�i���2��L�L��a�0�E������*�*�,�C��M�M�$�2�2�C�9�@�@��s�K�
M�rc��t�5|jjd�ddd�|jjdt��|j t
jjt��y#1swY�]xYw)Nzint('1')��filename)�silent�profilermodule�runr�
assertTrue�os�path�existsrs r�test_runzProfileTest.test_runYsZ��
�X����#�#�J�/�������
�V��<���������v�.�/��X�s�B�Bc�f�t�5|jjdt�t ��ddd�|jjdt�t �t
��|j
tjjt
��y#1swY�oxYw)NrrZ)
r\r]r'r(r)rr_r`rarbrs r�test_runctxzProfileTest.test_runctx_so��
�X����&�&�|�W�Y���I�����"�"�<���F�H�+1� #� 3���������v�.�/� �X�s�.B'�'B0c���td|jjd�td|jjdd�td|jjdddd�y)N�-m�random_module_xyz�timeitz-n�1)rr]rGr
rs r�test_run_profile_as_modulez&ProfileTest.test_run_profile_as_modulefs]���d�D�$7�$7�$@�$@�$�G� �d�D�$7�$7�$@�$@�"�$7� 9� ��t�2�2�;�;��x��s� 4rc ��t�5}t|�5tjd�t ddd��5}|jd�ddd�t
d|jjdd d�|jtjjd ��ddd�ddd�y#1swY�kxYw#1swY�xYw#1swYyxYw)
N�destzdemo.py�wzutf-8)�encodingzimport os; os.chdir("dest")rgz-oz
out.pstats)rrr`�mkdir�open�writer
r]rGr_rarb)r�tmpdir�fs r�(test_output_file_when_changing_directoryz4ProfileTest.test_output_file_when_changing_directoryrs���
�Z�6�:�f�#5��H�H�V���i��w�7�1����5�6�8�
��d�)�)�2�2��l��
�
�O�O�B�G�G�N�N�<�8�9�$6�Z�Z�7�7��$6�#5��Z�Z�s:�C�$C�B7�
AC�&C�7C�<C�C �C�CN)rGr3�__qualname__�profile�Profiler&r]r+rSrr�classmethodrArPrXrcrerkru�rrrrsX���O�O�M��N�C�K�#��������('�"M�*0�0�
4�:rrc
��|jd�}td|z�|j�}g}t|d�5}|D]&}|j |�|jd�s�&nddd�t|d�5}|j
|�|jd�t|j�D]#\}}|jd|�d||d z�d
���%|jd�ddd�y#1swY��xYw#1swYyxYw)N�cozRegenerating %s...�rz#--cutrnz_ProfileOutput = {}
z_ProfileOutput[z ] = """\
r$z"""
z'
if __name__ == "__main__":
main()
)
r5�printrArqr*�
startswith�
writelinesrrrFr+)r[r7r8�newfilertr@rLrMs r�regenerate_expected_outputr��s������t�$�H� �
��
)�*���� �G��G�
�h�� ���D��N�N�4� ����x�(���
�
�h�� �� ���W�� ���'�(�"�3�?�?�3�I�A�v�
�G�G��G�A�a�C�L�*�
+�4�
���<�=�
� �
� ��
� �s�(C6�'C6�>A/D�6C?�Dc#�K�tj} t�t_d��|t_y#|t_wxYw�wr)�sys�stdoutr)r�s rr\r\�s.����
�Z�Z�F���Z��
�
���
��V��
�s�A�7�A�
A�Ac�z�dtjvrtj�yt t
t�y)Nz-r)r��argv�unittest�mainr��__file__rrzrrr�r��s!���3�8�8���
�
��"�8�[�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(exception) <- 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�r,r�r`�difflibr�ior�test.support.os_helperrrrr�
contextlibr rw�
test.profileer
r�test.support.script_helperrr
�TestCaserr�r\r�rrGrzrr�<module>r�s���(�
�
�� � ��G�G�%��)�N�m:�(�#�#�m:�`>�(����:��� !K��}��#L����$#R����&�z���F�r
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists