#NEWLINE# def run( self ) : #NEWLINE# #INDENT# self . setup_path ( ) #NEWLINE# def do( setup_statements , statement ) : #NEWLINE# #INDENT# t = timeit . Timer ( stmt = statement , setup = '\n' . join ( setup_statements ) ) #NEWLINE# for i in range ( 1 , 10 ) : #NEWLINE# #INDENT# number = ( 10 ** i ) #NEWLINE# x = t . timeit ( number ) #NEWLINE# if ( x >= 0.2 ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# return ( x / number ) #NEWLINE# #UNINDENT# def abbrev( t ) : #NEWLINE# #INDENT# if ( t > 1.0 ) : #NEWLINE# #INDENT# return ( '%.3fs' % t ) #NEWLINE# #UNINDENT# if ( t > 0.001 ) : #NEWLINE# #INDENT# return ( '%.2fms' % ( t * 1000.0 ) ) #NEWLINE# #UNINDENT# return ( '%.2fus' % ( t * 1000000.0 ) ) #NEWLINE# #UNINDENT# S1 = "import ed25519; msg=b'hello world'" #NEWLINE# S2 = 'sk,vk = ed25519.create_keypair()' #NEWLINE# S3 = 'sig = sk.sign(msg)' #NEWLINE# S4 = 'vk.verify(sig, msg)' #NEWLINE# generate = do ( [ S1 ] , S2 ) #NEWLINE# sign = do ( [ S1 , S2 ] , S3 ) #NEWLINE# verify = do ( [ S1 , S2 , S3 ] , S4 ) #NEWLINE# print ( ( 'generate: %s' % abbrev ( generate ) ) ) #NEWLINE# print ( ( 'sign: %s' % abbrev ( sign ) ) ) #NEWLINE# print ( ( 'verify: %s' % abbrev ( verify ) ) )