python (3.12.0)
Αe d dl Z d dlZd dlZd Zd Zd Zd Ze j d Zedv r$ e dez e d ez d
z e
ded ned
k( r_ ee j dkD rJd dlZ e de j d z e
de j d z e
ee j d ned
k( rJ ee j dk( r5d dlZ e de j d z e
de j d z nL eee r- e e
ee d r e
ee Z e
dez e
ee n e dez e
dez e e edd ed!d" ed#d$ ed%d& ed'd( ed)d* ed+d, e e j d- ed.d/ y# e$ r@ e
e
d e
d e
d e
d e
d e
d e
w xY w)0 Nc t d )Nzeek, creatorFunc not overridden)RuntimeError E/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/test/time_hashlib.pycreatorFuncr s
8
99r c d| z dz }d| z }t }t j }t | D ] } || j } t j }t d||z
z d|dt
| d| y )Nٞ Z%2.2fsecondsxbytes)r timeperf_counterrangedigestprintlen) scalename
iterationslongStrlocalCFstartfr ends r test_scaled_msgr s #J5jGGE
:
&G##%&
C 7c%i 9j#s7|WVZ[r c t j } t d D ] }t } t j }t d|| z
z dd 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.ABr c t j } t d D ] }t j } t j }t d|| z
z dd 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.BCr )_md5_shazimport zcreatorFunc = z.newztesting speed of oldzlegacy interface_hashlib zcreatorFunc = _hashlib.%s ztesting speed of _hashlib.%sz+creatorFunc = lambda x=_hashlib.new : x(%r)z!testing speed of _hashlib.new(%r)__call__ztesting 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% argvhNameexecr r r) getattrhasattr
ValueErrordigest_sizer r r <module>r9 s0 :
\CD
5 % &'
%);<
jS]Q. $sxx{ 23
(388A;
6#((ST+8VW
jS]a/ 6! DE
-
;<We%)@*!M'5)K
%e
+WWe-DE 5 =>
,u
45
M
f= 1 e. 1 d 1 c 0 1 c 0 1 c 0 1 c / km//6J K b} -)
G
DE
BC
IJ
BC
JK
:; G
s
G AH