summaryrefslogtreecommitdiff
path: root/python/PyECC/ecc/performance.py
blob: 724176aef89e59f629fcbda990f17fe9f64967bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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))