
    <e                        d dl Z d dlZd dlZd Zd Zd Zd Ze j        d         Zedv r. e	dez               e	d	ez   d
z               e
ded           nedk    ra ee j                  dk    rMd dlZ e	de j        d         z              e
de j        d         z   eee j        d                              nedk    rK ee j                  dk    r7d dlZ e	de j        d         z              e
de j        d         z             nd eee          r< e eee          d          r& eee          Z e
dez    eee                     n e	dez              e
dez             	  e             n`# e$ rX  e
              e
d            e
d            e
d            e
d            e
d            e
d            e
              w xY w e              edd             ed!d"             ed#d$             ed%d&             ed'd(             ed)d*             ed+d,             e e            j        d-             ed.d/            dS )0    Nc                       t          d          )Nzeek, creatorFunc not overridden)RuntimeError     (/usr/lib/python3.11/test/time_hashlib.pycreatorFuncr   	   s    
8
9
99r   c           	      (   d| z  dz  }d| z  }t           }t          j                    }t          |          D ]} ||                                          } t          j                    }t          d||z
  z  d|dt          |          d|           d S )Nٞ       Z%2.2fsecondsxbytes)r   timeperf_counterrangedigestprintlen)	scalename
iterationslongStrlocalCFstartfr   ends	            r   test_scaled_msgr      s    #J5jGGE: & &GG##%%



C	7c%i 9j#s7||WVZ[[[[[r   c                      t          j                    } t          d          D ]}t                      }t          j                    }t	          d|| z
  z  dd           d S )N N  r   r   z[20000 creations])r   r   r   r   r   )r   r   dr   s       r   test_creater#      s`    E5\\  MM



C	7c%i 9.ABBBBBr   c                      t          j                    } t          d          D ]"}t                                                      }#t          j                    }t          d|| z
  z  dd           d S )Nr!   r   r   z[20000 "" digests])r   r   r   r   r   r   )r   r   r   r   s       r   	test_zeror%       sl    E5\\ # #MM  ""



C	7c%i 9.BCCCCCr      )_md5_shazimport zcreatorFunc = z.newztesting speed of oldzlegacy interface_hashlib   zcreatorFunc = _hashlib.%s   ztesting speed of _hashlib.%sz+creatorFunc = lambda x=_hashlib.new : x(%r)z!testing speed of _hashlib.new(%r)__call__ztesting speed of hashlib.z*creatorFunc = lambda x=hashlib.new : x(%r)z testing speed of hashlib.new(%r)z8pass argument(s) naming the hash to run a speed test on:z6 '_md5' and '_sha' test the legacy builtin md5 and shaz= '_hashlib' 'openssl_hName' 'fast' tests the builtin _hashlibz6 '_hashlib' 'hName' tests builtin _hashlib.new(shaFOO)z> 'hName' tests the hashlib.hName() implementation if it existsz.         otherwise it uses hashlib.new(hName).r
   z[huge data])r   r   i|)  z[large data]i&  z[medium data]i  z[4*small data]iP  z[3*small data]   z[2*small data]j   z[small data]z[digest_size data]
   z[tiny data])sysr   hashlibr   r   r#   r%   argvhNameexecr   r   r)   getattrhasattr
ValueErrordigest_sizer   r   r   <module>r9      s   


  : : :
\ 
\ 
\C C CD D D 	
 	D5D	%		&'''	E
 %);<<<<
jSS]]Q..OOOD	$sx{	2333	E
(38A;
6#(ST+8V8VWWWW
jSS]]a//OOOD	6!	DEEE	E
-
;<<<<WWe 6%)@)@*!M!M 6''5))K	E
%e
+WWWe-D-DEEEED	5	=>>>	E
,u
4555
KMMMM 	
 	
 	
	EGGG	E
DEEE	E
BCCC	E
IJJJ	E
BCCC	E
JKKK	E
:;;;	EGGG		
 
	 f= 1 1 1 1 e. 1 1 1 1 d 1 1 1 1 c 0 1 1 1 1 c 0 1 1 1 1 c 0 1 1 1 1 c / / / / kkmm/6J K K K K b} - - - - - -s   5
F   AG