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__/sortperf.cpython-38.pyc
U

>��g��@svdZddlZddlZddlZddlZddlZddlZe��Zdd�Z	dd�Z
dd�Zd	d
�Zdd�Z
ed
krre
�dS)z_Sort performance test.

See main() for command line syntax.
See tabulate() for output format.

�NcsDtj�td|�}zt|d�}Wn�tk
r�tj��fdd�t|�D�}zVz&t|d�}t	�
||�|��d}W5|r�zt�|�Wntk
r�YnXXWn0tk
r�}ztd|d|�W5d}~XYnXYnVXt	�
|�}|��td	�D]8}t�|�}|d|�}|d|�=|��|�|�~q�t|�|k�s@t�|S)
z+Return a list of n random floats in [0, 1).zrr%06d�rbcsg|]
}���qS�r)�.0�i��rr�,/opt/cppython/lib/python3.8/test/sortperf.py�
<listcomp>szrandfloats.<locals>.<listcomp>�wbNzcan't write�:�
)�os�path�join�td�open�OSError�random�range�unlink�marshal�dump�close�print�load�	randrange�reverse�extend�len�AssertionError)�n�fn�fp�result�msgrZtemprrr�
randfloatss<
&



r%cCstj��dS�N)�sys�stdout�flushrrrrr)8sr)cCs6t��}|��t��}td||dd�t�dS)Nz%6.2f� ��end)�time�perf_counter�sortrr))�L�t0�t1rrr�doit;s
r3c
Cs�tdd�dD��}ddt|�}t|d|�|D�]�}d|>}t|�}td||fd	d
�t�t|�|��t|�t|�td�D]2}t�	|�}t�	|�}||||||<||<q�t|�|dkr�d
d�td�D�|dd�<t|�t|d�D]}t��|t�	|�<�qt|�|dk�rT|dd�=||d}t
tdd�|��}t|�~t
ttdg|��}t|�~|d}	t
t|	ddd��}|�
t|	��t
tt|��}t|�t�q6dS)a:Tabulate sort speed for lists of various sizes.

    The sizes are 2**i for i in r (the argument, a list).

    The output displays i, 2**i, and the time to sort arrays of 2**i
    floating point numbers with the following properties:

    *sort: random data
    \sort: descending data
    /sort: ascending data
    3sort: ascending, then 3 random exchanges
    +sort: ascending, then 10 random at the end
    %sort: ascending, then randomly replace 1% of the elements w/ random values
    ~sort: many duplicates
    =sort: all equal
    !sort: worst case scenario

    cSsg|]}|d�qS)r/r)rZchrrrr	Usztabulate.<locals>.<listcomp>z	*\/3+%~=!z%2s %7sz %6s)rz2**i�z%2d %7dr*r+�rcSsg|]}t���qSr)r)r�dummyrrrr	ksi����N�d�cSs|Sr&r)�xrrr�<lambda>y�ztabulate.<locals>.<lambda>g�����)�tuplerrr%r)r3rrrr�list�map�absr�float)
rZcases�fmtrr r0r6Zi1Zi2Zhalfrrr�tabulateBsL




rDcCs�d}d}tjdd�r�ttjd�}}tjdd�r�ttjd�}tjdd�r�d}tjdd�D]}d|t|�}qdt�|�t||d�}t|�dS)z�Main program when invoked as a script.

    One argument: tabulate a single row.
    Two arguments: tabulate a range (inclusive).
    Extra arguments are used to seed the random generator.

    ��r4Nr<r5i�
)r'�argv�int�hashr�seedrrD)Zk1Zk2r9�arrrr�main�s	
rL�__main__)�__doc__r'r-rr�tempfiler
�
gettempdirrr%r)r3rDrL�__name__rrrr�<module>s'L

F1le Man4ger