forked from uni-due-syssec/efcf-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsummarize-throughput.py
More file actions
executable file
·120 lines (110 loc) · 4.23 KB
/
Copy pathsummarize-throughput.py
File metadata and controls
executable file
·120 lines (110 loc) · 4.23 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env python
import string
import csv
import datetime as dt
import re
import sys
import os
from pathlib import Path
def runtime_str_to_delta(runtime):
try:
t = dt.datetime.strptime(runtime, "%H:%M:%S.%f")
except ValueError:
try:
t = dt.datetime.strptime(runtime, "%M:%S.%f")
except ValueError:
t = dt.datetime.strptime(runtime, "%S.%f")
delta = dt.timedelta(hours=t.hour, minutes=t.minute, seconds=t.second)
return delta
ECHIDNA_LINE_RE = re.compile(r'echidna.+: fuzzing \(([0-9]+)/[0-9]+\)')
csv_header_fields = [
"tool", "contract", "run", "throughput", "metric", "runtime"
]
with open(os.path.abspath(sys.argv[1]), "w", newline='') as f:
csvw = csv.DictWriter(f, fieldnames=(csv_header_fields))
csvw.writeheader()
for cflog in Path("./results/tools-throughput/").glob("confuzzius.*.log"):
components = str(cflog.name).split(".")
contract = components[1]
run = int(components[2].strip())
runtime = None
num = None
with cflog.open() as f:
for line in f.readlines():
line = line.strip()
if "Transactions per second" in line:
num = line.split(":")[-1].strip()
num = int(num)
if "Elapsed" in line and "time" in line:
runtime = line.split(" ")[-1]
delta = runtime_str_to_delta(runtime)
runtime_secs = delta.total_seconds()
if num is None or runtime_secs is None:
print("incomplete => confuzzius on", contract, "run", run, "num", num, 'runtime', runtime_secs)
r = {
'tool': "confuzzius",
'metric': 'tx / sec',
'contract': contract,
'run': run,
'throughput': num,
'runtime': runtime_secs,
}
csvw.writerow(r)
for cflog in Path("./results/tools-throughput/").glob(
"echidnaprime.*.log"):
components = str(cflog.name).split(".")
contract = components[1]
run = int(components[2].strip())
num = None
runtime_secs = None
with cflog.open() as f:
for line in f.readlines():
line = line.strip(string.whitespace)
m = ECHIDNA_LINE_RE.search(line)
if m and num is None:
num = m.groups()[0]
num = int(num)
if "Elapsed" in line and "time" in line:
runtime = line.split(" ")[-1]
delta = runtime_str_to_delta(runtime)
runtime_secs = delta.total_seconds()
if num is None or runtime_secs is None:
print("incomplete => echidna on", contract, "run", run, "num", num, 'runtime', runtime_secs)
r = {
'tool': "echidna",
'metric': 'testcase / sec',
'contract': contract,
'run': run,
'throughput': num / runtime_secs if num else None,
'runtime': runtime_secs,
}
csvw.writerow(r)
for cflog in Path("./results/tools-throughput/").glob(
"echidna2.*.log"):
components = str(cflog.name).split(".")
contract = components[1]
run = int(components[2].strip())
num = None
runtime_secs = None
with cflog.open() as f:
for line in f.readlines():
line = line.strip(string.whitespace)
m = ECHIDNA_LINE_RE.search(line)
if m and num is None:
num = m.groups()[0]
num = int(num)
if "Elapsed" in line and "time" in line:
runtime = line.split(" ")[-1]
delta = runtime_str_to_delta(runtime)
runtime_secs = delta.total_seconds()
if num is None or runtime_secs is None:
print("incomplete => echidna2 on", contract, "run", run, "num", num, 'runtime', runtime_secs)
r = {
'tool': "echidna2",
'metric': 'testcase / sec',
'contract': contract,
'run': run,
'throughput': num / runtime_secs if num else None,
'runtime': runtime_secs,
}
csvw.writerow(r)