Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
analyze_bench.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2
3import sys
4import math
5import statistics
6
7def mean(d):
8 return sum(d)*1.0/len(d)
9
10def deviation(d):
11 m = mean(d)
12 return math.sqrt(sum((x-m)**2 for x in d)*1.0/len(d))
13
14keys = set()
15validate = {}
16action = {}
17torsion = {}
18mults = {}
19sqs = {}
20adds = {}
21num = 0
22
23for line in sys.stdin:
24 line = line.split()
25 if len(line) < 11: continue
26 if line[3] != 'mulsq': continue
27 if line[5] != 'sq': continue
28 if line[7] != 'addsub': continue
29 if line[9] != 'cycles': continue
30
31 if line[2] == 'validate':
32 target = validate
33 elif line[2] == 'action':
34 target = action
35 elif line[2] == 'torsionpoint':
36 target = torsion
37 elif line[2] == 'mults':
38 target = mults
39 elif line[2] == 'sqs':
40 target = sqs
41 elif line[2] == 'adds':
42 target = adds
43 else:
44 continue
45
46 mul = int(line[4])
47 sq = int(line[6])
48 addsub = int(line[8])
49 Mcyc = 0.000001*int(line[10])
50 mulsq = mul+sq
51 combo185 = mul+0.8*sq+0.05*addsub
52
53 keys.add(int(line[1]))
54 for k in int(line[1]),'total':
55 for name,value in (
56 ('Mcyc',Mcyc),
57 ('mulsq',mulsq),
58 ('sq',sq),
59 ('addsub',addsub),
60 ('mul',mul),
61 ('combo185',combo185),
62 ):
63 if (k,name) not in target:
64 target[k,name] = []
65 target[k,name] += [value]
66
67 num += 1
68
69for k in sorted(keys)+['total']:
70 for targetname,target in (
71 ('validate',validate),
72 ('action',action),
73 ('torsionpoint',torsion),
74 ('mults',mults),
75 ('sqs',sqs),
76 ('adds',adds),
77 ):
78 if target == {}:
79 continue
80 output = '%s %s' % (k,targetname)
81 output += ' experiments %d' % len(target[k,'Mcyc'])
82 for name in ('Mcyc','mulsq','sq','addsub','mul','combo185'):
83 x = target[k,name]
84 format = ' %s %.0f+-%.0f'
85 if name == 'Mcyc':
86 format = ' %s %.5f+-%.5f'
87 output += format%(name,statistics.median(x),deviation(x))
88 print(output)