def bench_hashes(MAXTIME): for klass in generate_hash_benchers(): print klass ob = klass() for (legend, size) in [ ("large (%d B)", 10**7), ]: print legend % size rep_bench(ob.proc, size, UNITS_PER_SECOND=UNITS_PER_SECOND, MAXTIME=MAXTIME, MAXREPS=100, initfunc=ob.proc_init) print print "nanoseconds per byte hashed" print
def bench_ciphers(MAXTIME): for (klass, keysize) in [ (aes.AES, 16), (aes.AES, 32), (xsalsa20.XSalsa20, 32), ]: ob = BenchCrypt(klass, keysize) print ob for (legend, size) in [ ("large (%d B)", 10**7), ]: print legend % size rep_bench(ob.crypt, size, UNITS_PER_SECOND=UNITS_PER_SECOND, MAXTIME=MAXTIME, MAXREPS=100, initfunc=ob.crypt_init) print print "nanoseconds per byte crypted" print
def bench_sigs(MAXTIME): for klass in [ECDSA256, Ed25519,]: print klass ob = klass() print "generate key" rep_bench(ob.gen, 1000, UNITS_PER_SECOND=1000, MAXTIME=MAXTIME, MAXREPS=100) print "sign" rep_bench(ob.sign, 1000, UNITS_PER_SECOND=1000, initfunc=ob.sign_init, MAXTIME=MAXTIME, MAXREPS=100) print "verify" rep_bench(ob.ver, 1000, UNITS_PER_SECOND=1000, initfunc=ob.ver_init, MAXTIME=MAXTIME, MAXREPS=100) print for klass in [RSA2048, RSA3248]: print klass ob = klass() print "generate key" rep_bench(ob.gen, 1, UNITS_PER_SECOND=1000, MAXTIME=MAXTIME, MAXREPS=100) print "sign" rep_bench(ob.sign, 1000, UNITS_PER_SECOND=1000, initfunc=ob.sign_init, MAXTIME=MAXTIME, MAXREPS=100) print "verify" rep_bench(ob.ver, 10000, UNITS_PER_SECOND=1000, initfunc=ob.ver_init, MAXTIME=MAXTIME, MAXREPS=100) print print "milliseconds per operation" print