
    daf                         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       nedk(  r_ ee j                        dkD  rJd dlZ e	de j                  d   z          e
de j                  d   z   eee j                  d                nedk(  rJ ee j                        dk(  r5d dlZ e	de j                  d   z          e
de j                  d   z         nL 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         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/        y# e$ r@  e
         e
d        e
d        e
d        e
d        e
d        e
d        e
         w xY w)0    Nc                      t        d      )Nzeek, creatorFunc not overridden)RuntimeError     ,/root/Python-3.12.4/Lib/test/time_hashlib.pycreatorFuncr   	   s    
8
99r   c           	         d| z  dz  }d| z  }t         }t        j                         }t        |      D ]  } ||      j	                         } t        j                         }t        d||z
  z  d|dt        |      d|       y )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: &G##%&



C	7c%i 9j#s7|WVZ[r   c                      t        j                         } t        d      D ]  }t               } t        j                         }t	        d|| z
  z  dd       y )N N  r   r   z[20000 creations])r   r   r   r   r   )r   r   dr   s       r   test_creater#      sN    E5\ M



C	7c%i 9.ABr   c                      t        j                         } t        d      D ]  }t               j	                         } t        j                         }t        d|| z
  z  dd       y )Nr!   r   r   z[20000 "" digests])r   r   r   r   r   r   )r   r   r   r   s       r   	test_zeror%       sW    E5\ #M  "#



C	7c%i 9.B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      s0     :
\CD 	
 	5	%		&'	
 %);<
jS]Q.	$sxx{	23	
(388A;
6#((ST+8VW
jS]a/	6!	DE	
-
;<We%)@*!M'5)K	
%e
+WWe-DE	5	=>	
,u
45
M 
 f= 1 e. 1 d 1 c 0 1 c 0 1 c 0 1 c / km//6J K b} -)  	
	G	
DE	
BC	
IJ	
BC	
JK	
:;	G		
s   G AH