HEX
Server: Apache
System: Linux bd12.noc223.com 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: handcraf (1693)
PHP: 8.1.28
Disabled: NONE
Upload Files
File: //proc/self/root/opt/alt/python312/lib64/python3.12/test/__pycache__/sortperf.cpython-312.opt-1.pyc
�

~h�e����dZddlZddlZddlZddlZddlZddlZej�Zd�Z	d�Z
d�Zd�Zd�Z
edk(re
�yy)	z_Sort performance test.

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

�Nc�B�tjjtd|z�}	t	|d�}tj|�}|j�td�D]C}tj|�}|d|}|d|�=|j�|j|�~�E|S#t$r�tj}t|�D�cgc]	}|���ncc}w}}		t	|d�}tj||�|j�d}|rS	tj|�n<#t$rYn1wxYw#r&	tj|�w#t$rYwwxYwwxYwY|S#t$r}t!d|d|�Yd}~Y|Sd}~wwxYwwxYw)z+Return a list of n random floats in [0, 1).zrr%06d�rb�
N�wbzcan't write�:)�os�path�join�td�open�marshal�load�close�range�random�	randrange�reverse�extend�OSError�dump�unlink�print)�n�fn�fp�result�i�temp�r�msgs        �4/opt/alt/python312/lib64/python3.12/test/sortperf.py�
randfloatsr"s���

�����b�(�Q�,�	'�B��
�"�d�^��&���b�!��
���
��r��	�A�� � ��#�A��"�1�:�D��r��r�
��L�L�N��M�M�$���
	��M��;�/��M�M��$�Q�x�(�!�!�#�(��(��(�
	/�

��"�d�^�����V�R�(����
������	�	�"�
��"��������	�	�"�
��"�������&�M���	/��-��S�#�.�.��M��	/��/�s��B-�-&F�C"�!F�+4E�E7�"D8�7E7�8	E�E7�E�E7�E1�E!� E1�!	E-	�*E1�,E-	�-E1�1E7�7	F�F�F�F�Fc�@�tjj�y�N)�sys�stdout�flush��r!r'r'8s���J�J���r)c��tj�}|j�tj�}td||z
zd��t	�y)Nz%6.2f� ��end)�time�perf_counter�sortrr')�L�t0�t1s   r!�doitr4;s?��	
�	�	�	�B��F�F�H�	
�	�	�	�B�	�'�R��U�
��%�	�Gr)c��tdD�cgc]}|dz��	c}�}ddt|�zz}t|d|zz�|D�]�}d|z}t|�}td||fzd�	�t	�t|�|j
�t|�t|�td
�D]=}tj|�}tj|�}	||	||c||<||	<�?t|�|dk\r.td�D�cgc]}tj���c}|dd
t|�t|dz�D],}tj�|tj|�<�.t|�|dkDr#|dd
�=||dzz}ttd�|��}t|�~tttdg|z��}t|�~|dz}
tt|
dz
dd��}|jt|
��ttt|��}t|�t���y
cc}wcc}w)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

    z	*\/3+%~=!r0z%2s %7sz %6s)rz2**i�z%2d %7dr+r,�ri����N�d�c�
�|Sr$r()�xs r!�<lambda>ztabulate.<locals>.<lambda>ys
��Q�B�3�r)g�����)�tuple�lenrr"r'r4rrrr�list�map�absr�float)r�ch�cases�fmtrrr1�dummy�i1�i2�halfs           r!�tabulaterLBs��&
��6�2�2��;�6�7�E��v�c�%�j�(�(�C�	�#���&�
'�(�
�4��
��F���q�M��
�i�1�a�&� �c�*�
���Q��	�	�	���Q���Q���1�X�	(�E��!�!�!�$�B��!�!�!�$�B��R�5�!�B�%�L�A�b�E�1�R�5�	(�	
�Q��
��7�49�"�I�>�5�v�}�}��>�A�c�d�G��Q���1��8�_�	5�E�%+�]�]�_�A�f���q�!�"�	5��Q��
�q�5��!�"���Q�!�V��A��S���*�+�A��Q��
�
��S�4�&�1�*�%�&���Q��
�
�A�v����t�a�x��R�(�)��	����t���
��U�A�����Q��
��i4��7��,?s�I�
I
c��d}d}tjddr�ttjd�x}}tjddrottjd�}tjddr@d}tjddD]}d|zt|�z}�t	j
|�t
||dz�}t|�y)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.

    ��r6Nr=r7i�
)r%�argv�int�hashr�seedrrL)�k1�k2r;�ars     r!�mainrW�s���
�B�	�B�
�x�x���|��c�h�h�q�k�"�"��R��8�8�A�B�<��S�X�X�a�[�!�B��x�x���|������!�"��,�A���	�D��G�+�A�,����A��
�b�"�Q�$��A��Q�Kr)�__main__)�__doc__r%r.rr
�tempfiler�
gettempdirrr"r'r4rLrW�__name__r(r)r!�<module>r]s^�����
���	��X�����%�N��J�X�4�z���F�r)