mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-05 15:28:39 +09:00
import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
This commit is contained in:
commit
dcd9973243
150858 changed files with 23884658 additions and 0 deletions
50
python/PyECC/ecc/performance.py
Normal file
50
python/PyECC/ecc/performance.py
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
from Key import Key
|
||||
import time
|
||||
from collections import OrderedDict
|
||||
|
||||
def test_generation_perf(n = 100):
|
||||
results = OrderedDict()
|
||||
for bits in (192, 224, 256, 384, 521):
|
||||
t = time.time()
|
||||
for i in xrange(n):
|
||||
k = Key.generate(bits)
|
||||
t = time.time() - t
|
||||
results[bits] = t
|
||||
return results
|
||||
|
||||
def test_signing_perf(n = 100):
|
||||
results = OrderedDict()
|
||||
for bits in (192, 224, 256, 384, 521):
|
||||
k = Key.generate(bits)
|
||||
t = time.time()
|
||||
for i in xrange(n):
|
||||
k.sign("random string")
|
||||
t = time.time() - t
|
||||
results[bits] = t
|
||||
return results
|
||||
|
||||
def test_verification_perf(n = 100):
|
||||
results = OrderedDict()
|
||||
for bits in (192, 224, 256, 384, 521):
|
||||
k = Key.generate(bits)
|
||||
s = k.sign("random string")
|
||||
t = time.time()
|
||||
for i in xrange(n):
|
||||
k.verify("random string", s)
|
||||
t = time.time() - t
|
||||
results[bits] = t
|
||||
return results
|
||||
|
||||
def print_dict(title, d):
|
||||
print title
|
||||
print '-' * len(title)
|
||||
for k, v in d.items():
|
||||
print k, '\t', v
|
||||
print
|
||||
|
||||
n = 100
|
||||
print_dict("Key generation", test_generation_perf(n))
|
||||
print_dict("Signing", test_signing_perf(n))
|
||||
print_dict("Verifying", test_verification_perf(n))
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue