Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 3.21.12.244
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : test_timeit.cpython-310.pyc
o

ab�<�@s�ddlZddlZddlZddlZddlmZddlmZddlmZdZ	dZ
Gdd�d�ZGd	d
�d
ej�Z
edkr@e��dSdS)�N)�dedent)�captured_stdout)�captured_stderri@B�c@s:eZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�	FakeTimergE@��?cCsd|_d|_||_|t_dS)Nr)�count�setup_calls�seconds_per_increment�timeit�_fake_timer)�selfr
�r�9/usr/local/python-3.10/lib/python3.10/test/test_timeit.py�__init__s
zFakeTimer.__init__cCs|j|j|jS�N)�	BASE_TIMErr
�r
rrr�__call__�zFakeTimer.__call__cC�|jd7_dS�N�)rrrrr�inc!rz
FakeTimer.inccCrr)r	rrrr�setup$rzFakeTimer.setupcCs
||_|S)z3Records 'timer' and returns self as callable timer.)Zsaved_timer)r
�timerrrr�
wrap_timer'szFakeTimer.wrap_timerN)r)	�__name__�
__module__�__qualname__rrrrrrrrrrrs
rc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dZdZdd�Z
dd�Zdkdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zdkd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Z d<d=�Z!d>Z"dld@dA�Z#dBdC�Z$dDdE�Z%dFdG�Z&dHdI�Z'dJdK�Z(dLdM�Z)dNdO�Z*dPdQ�Z+dRdS�Z,e-�.e/j0j1dTkdU�dVdW��Z2dXdY�Z3dZd[�Z4d\d]�Z5d^d_�Z6d`da�Z7dmdcdd�Z8dedf�Z9dgdh�Z:didj�Z;dS)n�
TestTimeitcCs zt`WdStyYdSwr)rr�AttributeErrorrrrr�tearDown.s

�zTestTimeit.tearDowncC�,|�t�dd�d�|�t�dd�d�dS)N�r���assertEqualrZreindentrrrr�test_reindent_empty4�zTestTimeit.test_reindent_emptycCr#)N�passrr%r&rrrr�test_reindent_single8r)zTestTimeit.test_reindent_singlecC�,|�t�dd�d�|�t�dd�d�dS)Nz

rr%z

    
    r&rrrr�test_reindent_multi_empty<r)z$TestTimeit.test_reindent_multi_emptycCr,)Nzprint()
pass
breakrr%zprint()
    pass
    breakr&rrrr�test_reindent_multi@s����zTestTimeit.test_reindent_multicCs�|jttjdd�|jttjdd�|jttjdd�|jttjdd�|jttjdd�|jttjdd�|jttjdd�|jttjdd�|jttjd	d
d�dS)N��stmt�return�yield�
yield from ()�break�continue�from timeit import *�  passzwhile False:
  passz  break)rr0��assertRaises�
ValueErrorr�Timer�SyntaxErrorrrrr�test_timer_invalid_stmtHs

�z"TestTimeit.test_timer_invalid_stmtcCs�|jttjdd�|jttjdd�|jttjdd�|jttjdd�|jttjdd�|jttjdd�|jttjdd�|jttjdd�dS)	N)rr1r2r3r4r5r6r7r8rrrr�test_timer_invalid_setupTsz#TestTimeit.test_timer_invalid_setupcCs(tjdd�tjdd�tjdd�dS)Nr$r/z 
	z	# comment)rr;rrrr�test_timer_empty_stmt^�z TestTimeit.test_timer_empty_stmtz(import timeit
timeit._fake_timer.setup()z&import timeit
timeit._fake_timer.inc()cC�|j��dSr)�
fake_timerrrrrr�fake_callable_setupf�zTestTimeit.fake_callable_setupcCrAr)rBrrrrr�fake_callable_stmtirDzTestTimeit.fake_callable_stmtNcCsvt�|_tj|||j|d�}i}|durt}n||d<|jdi|��}|�|jjd�|�|jj|�|�||�dS)N)r0rr�globals�numberrr)rrBrr;�DEFAULT_NUMBERr'r	r)r
r0rrGrF�t�kwargs�
delta_timerrrrls�zTestTimeit.timeitcC�|j|j|jdd�dS�Nr�rG�r�	fake_stmt�
fake_setuprrrr�test_timeit_zero_iters~�z!TestTimeit.test_timeit_zero_iterscCrL�N�rNrOrrrr�test_timeit_few_iters�rSz TestTimeit.test_timeit_few_iterscCrLrT)rrErQrrrr�test_timeit_callable_stmt�rSz$TestTimeit.test_timeit_callable_stmtcCrLrT)rrPrCrrrr�test_timeit_callable_setup�rSz%TestTimeit.test_timeit_callable_setupcCrLrT)rrErCrrrr�#test_timeit_callable_stmt_and_setup�s
�z.TestTimeit.test_timeit_callable_stmt_and_setupcCs(tj|j|jdt�d�}|�|d�dS)Nr�rGr)rrPrQrr')r
rKrrr�test_timeit_function_zero_iters���z*TestTimeit.test_timeit_function_zero_iterscCsXt�atjdtd�}|jt|jdd�tjdtt�dd�t�}tjd|t�dd�dS)Nz_global_timer.inc())r0rrUrN)r0rrFrGzlocal_timer.inc())rZ
_global_timerrr;r9�	NameErrorrF�locals)r
rIZlocal_timerrrr�test_timeit_globals_args�s�
�z#TestTimeit.test_timeit_globals_argscCs�t�|_tj|||jd�}i}|durt}n||d<|dur!t}n||d<|jdi|��}|�|jj|�|�|jj	||�|�||t
|�g�dS)N�r0rr�repeatrGr)rrBrr;�DEFAULT_REPEATrHrar'r	r�float)r
r0rrarGrIrJ�delta_timesrrrra�szTestTimeit.repeatcCrL)Nr)ra�rarPrQrrrr�test_repeat_zero_reps�rSz TestTimeit.test_repeat_zero_repscCrLrMrerrrr�test_repeat_zero_iters�rSz!TestTimeit.test_repeat_zero_iterscC�|j|j|jddd�dS�NrUr)rarGrerrrr�test_repeat_few_reps_and_iters�sz)TestTimeit.test_repeat_few_reps_and_iterscCrhri)rarErQrrrr�test_repeat_callable_stmt��
�z$TestTimeit.test_repeat_callable_stmtcCrhri)rarPrCrrrr�test_repeat_callable_setup�rlz%TestTimeit.test_repeat_callable_setupcCrhri)rarErCrrrr�#test_repeat_callable_stmt_and_setup�rlz.TestTimeit.test_repeat_callable_stmt_and_setupcCs(tj|j|jdt�d�}|�|g�dS)Nr)rar)rrarPrQrr'�r
rdrrr�test_repeat_function_zero_reps�r\z)TestTimeit.test_repeat_function_zero_repscCs.tj|j|jdt�d�}|�|tdg�dS)NrrZg)rrarPrQrr'rbrorrr�test_repeat_function_zero_iters�s�z*TestTimeit.test_repeat_function_zero_iterscCsD|��}|�t|�d�|�|d�d��|�|d�|��dS)N�rZ	Traceback���)�
splitlinesZ
assertGreater�lenZ
assertTrue�
startswith)r
Z
exc_stringZexpected_exc_nameZ	exc_linesrrr�assert_exc_string�szTestTimeit.assert_exc_stringcCsFt��}t�d�}z|��Wn	|�|�Y|�|��d�dS)N�1/0�ZeroDivisionError)�io�StringIOrr;�	print_excrw�getvalue)r
�srIrrr�test_print_exc�s
zTestTimeit.test_print_excz"1 loop, best of 5: 1 sec per loop
rcCs�|dur	t|d�}|durg}n|dd�}|�|j�tjdd�}t��}tj||jd�Wd�n1s9wY|dd�tjdd�<|�	�S)N�r
)�argsZ_wrap_timer)
r�appendrP�sys�pathrr�mainrr})r
r
�switchesrr�Z
orig_sys_pathr~rrr�run_main�s
�zTestTimeit.run_maincC�"|jdgd�}|�|td��dS)Nz--bad-switch�r�zk            option --bad-switch not recognized
            use -h/--help for command line help
            �r�r'r�r
r~rrr�test_main_bad_switch��zTestTimeit.test_main_bad_switchcC�|jdd�}|�|d�dS)Ng@r�z$1 loop, best of 5: 5.5 sec per loop
�r�r'r�rrr�test_main_seconds�zTestTimeit.test_main_secondscCr�)Ng�I+�v?r�z'50 loops, best of 5: 5.5 msec per loop
r�r�rrr�test_main_milliseconds	r�z!TestTimeit.test_main_millisecondscC� |jddgd�}|�|d�dS)Ng�h㈵��>z-n100�r
r�z(100 loops, best of 5: 2.5 usec per loop
r�r�rrr�test_main_microseconds
�z!TestTimeit.test_main_microsecondscCr�)N�@�-n35r��$35 loops, best of 5: 2 sec per loop
r�r�rrr�test_main_fixed_itersr�z TestTimeit.test_main_fixed_iterscC�*|jdgd�d�}|�|dtd�dS)Nr�)r��-szprint("CustomSetup")r��CustomSetup
r��r�r'rbr�rrr�test_main_setup��
�zTestTimeit.test_main_setupcCr�)Nr�)r�r�za = "CustomSetup"r�zprint(a)r�r�r�r�r�rrr�test_main_multiple_setupsr�z$TestTimeit.test_main_multiple_setupscCr�)N�N@z-r9r�z#1 loop, best of 9: 60 sec per loop
r�r�rrr�test_main_fixed_reps!r�zTestTimeit.test_main_fixed_repscCr�)Nr�z-r-5r�z#1 loop, best of 1: 60 sec per loop
r�r�rrr�test_main_negative_reps%r�z"TestTimeit.test_main_negative_repsrrzneed __doc__cCs$|jdgd�}|�|tjd�dS)Nz-hr�� )r�r'r�__doc__r�rrr�test_main_help)szTestTimeit.test_main_helpcCr�)Nz-vr�z�                1 loop -> 1 secs

                raw times: 1 sec, 1 sec, 1 sec, 1 sec, 1 sec

                1 loop, best of 5: 1 sec per loop
            r�r�rrr�test_main_verbose0r�zTestTimeit.test_main_verbosecCs$|jddgd�}|�|td��dS)NgiUMu�>z-vvr�a�                1 loop -> 3e-05 secs
                2 loops -> 6e-05 secs
                5 loops -> 0.00015 secs
                10 loops -> 0.0003 secs
                20 loops -> 0.0006 secs
                50 loops -> 0.0015 secs
                100 loops -> 0.003 secs
                200 loops -> 0.006 secs
                500 loops -> 0.015 secs
                1000 loops -> 0.03 secs
                2000 loops -> 0.06 secs
                5000 loops -> 0.15 secs
                10000 loops -> 0.3 secs

                raw times: 300 msec, 300 msec, 300 msec, 300 msec, 300 msec

                10000 loops, best of 5: 30 usec per loop
            r�r�rrr�test_main_very_verbose:sz!TestTimeit.test_main_very_verbosecCs�|jdddgd�}|�|d�|jdddgd�}|�|d�|jdddgd�}|�|d	�t��}|jddd
gd�}Wd�n1sDwY|�|��d�dS)Ng�~j�t�h?z-uZsecr�z)100 loops, best of 5: 0.003 sec per loop
Zmsecz&100 loops, best of 5: 3 msec per loop
Zusecz*100 loops, best of 5: 3e+03 usec per loop
Zparsecz;Unrecognized unit. Please select nsec, usec, msec, or sec.
)r�r'rr})r
Zunit_secZ	unit_msecZ	unit_usec�error_stringio�invalidrrr�test_main_with_time_unitPs4��������
�z#TestTimeit.test_main_with_time_unitcCsHt��}|jdgd�}Wd�n1swY|�|��d�dS)Nrxr�ry�rr�rwr}�r
r�r~rrr�test_main_exceptionds�zTestTimeit.test_main_exceptioncCsJt��}|jddgd�}Wd�n1swY|�|��d�dS)Nz-n1rxr�ryr�r�rrr�test_main_exception_fixed_repsis�z)TestTimeit.test_main_exception_fixed_reps�P?cCs(t|d�}tj|j|j|d�}|�|�S)Nr�r`)rrr;rPrQ�	autorange)r
r
�callbackrrIrrrr�ns

zTestTimeit.autorangecCs(|��\}}|�|d�|�|d�dS)N���@�?�r�r'�r
�	num_loops�
time_takenrrr�test_autorangesr@zTestTimeit.test_autorangecCs,|jdd�\}}|�|d�|�|d�dS)Nrr�rr�r�rrr�test_autorange_secondxsz TestTimeit.test_autorange_secondcCsndd�}t��}|j|d�\}}Wd�n1swY|�|d�|�|d�d}|�|��|�dS)NcSstd�||��dS)Nz	{} {:.3f})�print�format)�a�brrrr�~sz9TestTimeit.test_autorange_with_callback.<locals>.callback)r�r�r�zQ1 0.001
2 0.002
5 0.005
10 0.010
20 0.020
50 0.049
100 0.098
200 0.195
500 0.488
)rr�r'r})r
r�r~r�r�Zexpectedrrr�test_autorange_with_callback}s�	z'TestTimeit.test_autorange_with_callback)NN)rNN)r�N)<rrrr"r(r+r-r.r=r>r?rQrPrCrErrRrVrWrXrYr[r_rarfrgrjrkrmrnrprqrwrZMAIN_DEFAULT_OUTPUTr�r�r�r�r�r�r�r�r�r��unittestZskipIfr��flags�optimizer�r�r�r�r�r�r�r�r�r�rrrrr ,sl




	



r �__main__)rr�r�rz�textwraprZtest.supportrrrHrbrZTestCaser rr�rrrr�<module>s f�
© 2025 GrazzMean