HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/__pycache__/sortperf.cpython-310.pyc
o

�i��@szdZddlZddlZddlZddlZddlZddlZe��Zdd�Z	dd�Z
dd�Zd	d
�Zdd�Z
ed
kr;e
�dSdS)z_Sort performance test.

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

�Ncsftj�td|�}zt|d�}Wnnty~tj��fdd�t|�D�}z=z&t|d�}t�	||�|�
�d}W|rLzt�|�WntyKYnwn|r`zt�|�Wwty_YwwwWnty{}z
td|d|�WYd}~nd}~wwYn+wt�
|�}|�
�td	�D]}t�|�}|d|�}|d|�=|��|�|�~q�t|�|ks�J�|S)
z+Return a list of n random floats in [0, 1).zrr%06d�rbcsg|]}���qS�r)�.0�i��rr�*/usr/local/lib/python3.10/test/sortperf.py�
<listcomp>szrandfloats.<locals>.<listcomp>�wbNzcan't write�:�
)�os�path�join�td�open�OSError�random�range�marshal�dump�close�unlink�print�load�	randrange�reverse�extend�len)�n�fn�fp�result�msgrZtemprrr�
randfloatssV
���������



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

r2c
Cs�tdd�dD��}ddt|�}t|d|�|D]�}d|>}t|�}td||fd	d
�t�t|�|��t|�t|�td�D]}t�	|�}t�	|�}||||||<||<qFt|�|dkrud
d�td�D�|dd�<t|�t|d�D]}t��|t�	|�<qt|�|dkr�|dd�=||d}t
tdd�|��}t|�~t
ttdg|��}t|�~|d}	t
t|	ddd��}|�
t|	��t
tt|��}t|�t�qdS)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	U�ztabulate.<locals>.<listcomp>z	*\/3+%~=!z%2s %7sz %6s)rz2**i�z%2d %7dr)r*�rcSsg|]}t���qSr)r)r�dummyrrrr	kr3i����N�d�cSs|Sr%r)�xrrr�<lambda>ysztabulate.<locals>.<lambda>g�����)�tuplerrr$r(r2rrrr�list�map�absr�float)
r�cases�fmtrrr/r6Zi1Zi2Zhalfrrr�tabulateBsN


�rDcCs�d}d}tjdd�rBttjd�}}tjdd�rBttjd�}tjdd�rBd}tjdd�D]
}d|t|�}q2t�|�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(r2rDrL�__name__rrrr�<module>s 'L
�