Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/test/__pycache__/test_profile.cpython-38.pyc
U

>��g�"�@s�dZddlZddlZddlZddlZddlmZddlmZddl	m
Z
mZmZm
Z
mZddlmZddlZddlmZmZddlmZmZGd	d
�d
ej�Zdd�Zed
d��Zdd�Zdd�ZiZded<ded<ded<edkr�e�dS)z"Test suite for the profile module.�N)�unified_diff)�StringIO)�TESTFN�run_unittest�unlink�temp_dir�
change_cwd)�contextmanager)�testfunc�timer)�assert_python_failure�assert_python_okc@speZdZejZeZdddgZdZdd�Z	dd�Z
ed	d
��Zdd�Z
d
d�Zdd�Zdd�Zdd�Zdd�ZdS)�ProfileTest�print_stats�
print_callers�
print_calleesz:0(max)cCstt�dS�N)rr��self�r�0/opt/cppython/lib/python3.8/test/test_profile.py�tearDownszProfileTest.tearDowncCstSr)�_ProfileOutputrrrr�get_expected_outputszProfileTest.get_expected_outputcs�g}|�td�}t�}|�dt�t��|�t�|�|jD]r}t�}tj	||d�}|�
��d�t||��|�
���}tj�dd�d��fdd�|D�}|�d	�|��q>|S)
N���MbP?�
testfunc()��streamZstdname�.�csg|]}�|kr|���qSr)�rstrip)�.0�line�Zmod_namerr�
<listcomp>/sz,ProfileTest.do_profiling.<locals>.<listcomp>�
)�
profilerclassr�runctx�globals�locals�append�methodnamesr�pstats�StatsZ
strip_dirsZ
sort_stats�getattr�getvalue�
splitlinesr
�
__module__�rsplit�join)�cls�results�profZstart_timerZ
methodname�s�stats�outputrr#r�do_profilings
zProfileTest.do_profilingcCs�|��}|��}|�|dd�g}t|j�D]`\}}||}||d}||kr.|�d|�d|jj�d��|�t	|�
d�|�
d�dd	��q.|r�|�d�|��dS)
Nri�rz
Stats.z output for z does not fit expectation:r%�)Zlineterm)
r:rZassertEqual�	enumerater+r*r&�__name__�extendr�split�failr3)rr5Zexpectedr@�i�method�a�brrr�
test_cprofile3s�
zProfileTest.test_cprofilec	Csxddddddg}|D]^}t�}|�td�}|�|t�t��tj||d�}|��|�	�}|�
|j|d	�||��qdS)
Nzmax([0])zmax([0], key=int)zmax([0], **dict(key=int))zmax(*([0],))zmax(*([0],), key=int)zmax(*([0],), **dict(key=int))rrz&Profiling {0!r} didn't report max:
{1})
rr&rr'r(r)r,r-rr/ZassertIn�expected_max_output�format)rZstmtsZstmtr7r6r8�resrrr�test_calling_conventionsDs"�

�z$ProfileTest.test_calling_conventionsc	CsDt��|j�d�W5QRX|jjdtd�|�tj�t��dS)Nzint('1')��filename)�silent�profilermodule�runr�
assertTrue�os�path�existsrrrr�test_runYszProfileTest.test_runc	CsTt��|j�dt�t��W5QRX|jjdt�t�td�|�tj�	t��dS)NrrJ)
rLrMr'r(r)rrOrPrQrRrrrr�test_runctx_s�zProfileTest.test_runctxcCs<td|jjd�td|jjdd�td|jjdddd�dS)N�-mZrandom_module_xyzZtimeitz-n�1)rrMr=r
rrrr�test_run_profile_as_modulefs
�
�z&ProfileTest.test_run_profile_as_modulecCszt��j}t|��Vt�d�tdd��}|�d�W5QRXtd|jjddd�|�	tj
�d��W5QRXW5QRXdS)N�destzdemo.py�wzimport os; os.chdir("dest")rUz-oz
out.pstats)rrrP�mkdir�open�writer
rMr=rOrQrR)rZtmpdir�frrr�(test_output_file_when_changing_directoryrs
�z4ProfileTest.test_output_file_when_changing_directoryN)r=r1�__qualname__�profileZProfiler&rMr+rFrr�classmethodr:rErIrSrTrWr^rrrrrs

rc	Cs�|�d�}td|�|��}g}t|d��(}|D]}|�|�|�d�r2qPq2W5QRXt|d��R}|�|�|�d�t|j	�D]"\}}|�d|||df�q�|�d	�W5QRXdS)
N�cozRegenerating %s...�rz#--cutrYz_ProfileOutput = {}
z _ProfileOutput[%r] = """\
%s"""
rz'
if __name__ == "__main__":
    main()
)
r �printr:r[r*�
startswith�
writelinesr\r<r+)rKr4r5�newfiler]r"rArBrrr�regenerate_expected_output�s$





�
rhccs&tj}zt�t_dVW5|t_XdSr)�sys�stdoutr)rjrrrrL�s

rLcCstt�dSr)rrrrrr�	test_main�srkcCs dtjkrt�n
ttt�dS)Nz-r)ri�argvrkrh�__file__rrrrr�main�s
rna�       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__rir,ZunittestrPZdifflibr�iorZtest.supportrrrrr�
contextlibr	r`Z
test.profileer
rZtest.support.script_helperrr
ZTestCaserrhrLrkrnrr=rrrr�<module>s.p
	


F1le Man4ger