3 ^O @s<ddlZddlZddlZddZddZddZdd Zejd Zed5krte d ee dede dednedkre ejdkrddl Z e dejde dejde e ejdnedkoe ejdkr ddl Z e dejde dejdnVeeerJee eedrJe eeZe dee eene dee dey eWnTek re e de de de d e d!e d"e YnXeed#d$d%ed&d'd%ed(d)d%ed*d+d%ed,d-d%ed.d/d%ed0d1d%eejd2d%ed3d4d%dS)6NcCs tddS)Nzeek, creatorFunc not overridden) RuntimeErrorrr)/usr/lib64/python3.6/test/time_hashlib.py creatorFunc src Csjd|d}d|}t}tj}xt|D]}||j}q*Wtj}td||d|dt|d|dS)NiٞZz%2.2fsecondsxbytes)rtimerangedigestprintlen) scalenameZ iterationsZlongStrZlocalCFstartfr endrrrtest_scaled_msg s rcCs@tj}xtdD] }t}qWtj}td||dddS)Ni Nz%2.2frz[20000 creations])r r rr)rrdrrrr test_creates  rcCsDtj}xtdD]}tj}qWtj}td||dddS)Ni Nz%2.2frz[20000 "" digests])r r rr r)rrr rrrr test_zero s r_md5_shazimport zcreatorFunc = z.newztesting speed of oldzlegacy interface_hashlibzcreatorFunc = _hashlib.%sztesting 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).iٞz [huge data])rri|)z [large data]i&z [medium data]iz[4*small data]iPz[3*small data]z[2*small data]jz [small data]z[digest_size data] z [tiny data])rr)sysr ZhashlibrrrrargvZhNameexecrrrgetattrhasattr ValueErrorZ digest_sizerrrrs\   "