-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcsv2ops.py
executable file
·87 lines (76 loc) · 1.92 KB
/
csv2ops.py
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import sys
import re
clients = []
seconds = []
tests = []
data = {}
# read in csv file
for line in sys.stdin:
# read the header
if not clients:
clients = [word for word in line.rstrip().split(', ')]
units = clients.pop(0)
continue
# read the data
seconds = [second for second in line.rstrip().split(', ')]
test = seconds.pop(0)
if test not in ['nop', 'pop', 'add64', 'add128', 'add256', 'sub64', 'sub128', 'sub256',
'mul64', 'mul128', 'mul256', 'div64', 'div128', 'div256', 'exp']:
continue
if test not in tests:
tests += [test]
if test not in data:
data[test] = {}
for i, second in enumerate (seconds):
client = clients[i]
data[test][client] = second
# run time scaled by number of operations
# print header
sys.stdout.write("(ns/OP)")
for client in clients:
if client == 'gas':
continue
sys.stdout.write(", " + client)
sys.stdout.write("\n")
# print the test, gas, nanos, ...
ops_per_loop = 324;
N_ops = 1000000*ops_per_loop
N_exp = 30000*ops_per_loop
for test in tests:
if test == 'exp':
N = N_exp
else:
N = N_ops
sys.stdout.write(test)
for client in clients:
if client == 'gas':
continue
nanos_per_op = float(data[test][client])*10**9/N
sys.stdout.write(", %.2f" % nanos_per_op)
sys.stdout.write("\n")
# run time scaled by number of operations and offset by estimated overhead
# print header
sys.stdout.write("\n(ns/OP-POP)")
for client in clients:
if client == 'gas':
continue
sys.stdout.write(", " + client)
sys.stdout.write("\n")
# print the test, gas, nanos, ...
N_pop = N_ops
for test in tests:
if test in ['nop', 'pop']:
continue
if test == 'exp':
N = N_exp
else:
N = N_ops
sys.stdout.write(test)
for client in clients:
if client == 'gas':
continue
nanos_per_op = float(data[test][client])*10**9/N
nanos_per_pop = float(data['pop'][client])*10**9/N_pop
nanos_per_op -= nanos_per_pop
sys.stdout.write(", %.2f" % nanos_per_op)
sys.stdout.write("\n")