3 Ø ÷^O c @s<ddlZddlZddlZdd„Zdd„Zdd„Zdd „Zejd Zed5krte d eƒe dedƒe dedƒnîedkrÆe ejƒdkrÆddl Z e dejdƒe dejde e ejdƒƒnœedkoÚe ejƒdkr ddl Z e dejdƒe dejdƒnVeeeƒrJee eeƒdƒrJe eeƒZe dee eeƒƒne deƒe deƒy eƒWnTek rÀe ƒe dƒe dƒe dƒe d ƒe d!ƒe d"ƒe ƒ‚YnXeƒed#d$d%ed&d'd%ed(d)d%ed*d+d%ed,d-d%ed.d/d%ed0d1d%eeƒjd2d%ed3d4d%dS)6iNcCs tdƒ‚dS)Nzeek, creatorFunc not overridden)Z RuntimeError©rrú)/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)NéÙžisZú%2.2fÚsecondsÚxZbytes)rÚtimeÚrangeÚdigestÚprintÚlen) ÚscaleÚnameZ iterationsZlongStrZlocalCFÚstartÚfrÚendrrrÚtest_scaled_msg s rcCs@tjƒ}xtdƒD] }tƒ}qWtjƒ}td||ddƒdS)Né Nrrz[20000 creations])rrrr )rrZdrrrrÚ test_creates  rcCsDtjƒ}xtdƒD]}tƒjƒ}qWtjƒ}td||ddƒdS)Nrrrz[20000 "" digests])rrrr r )rrrrrrrÚ test_zero s riÚ_md5Ú_shazimport zcreatorFunc = z.newztesting speed of oldzlegacy interfaceÚ_hashlibizcreatorFunc = _hashlib.%siztesting speed of _hashlib.%sz+creatorFunc = lambda x=_hashlib.new : x(%r)z!testing speed of _hashlib.new(%r)Z__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).rz [huge data])r r i|)z [large data]i&z [medium data]i¨z[4*small data]iPz[3*small data]iÔz[2*small data]ijz [small data]z[digest_size data]i z [tiny data])rr)ZsysrZhashlibrrrrZargvZhNameZexecr r rZgetattrZhasattrZ ValueErrorZ digest_sizerrrrZs\   "