forked from encryptogroup/ABY
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheval_PFE_perf.py
executable file
·79 lines (62 loc) · 3.5 KB
/
eval_PFE_perf.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
#!/usr/bin/env python
# This script evaluated the performance files generated by the ./run_PFE_perf.sh
# and writes the results to csv files
import csv
import os.path
import re
import statistics
import sys
if (len(sys.argv) != 2):
print("Usage: ./eval_perf.py perf_2020_01_01-1337")
sys.exit(1)
file_prefix = sys.argv[1][:20]
print("File prefix", file_prefix)
def get_timing(file_ref, prefix, label):
file_ref.seek(0)
values = [float(line.split()[2])/1000 for line in file_ref if line.startswith("[TIME] %s" % label)]
print("%s] %s: %9.2f ms" % (prefix, label.rjust(36, " "), statistics.mean(values)))
return statistics.mean(values)
def get_mem(file_ref, label):
file_ref.seek(0)
values = [int(line.split()[2]) for line in file_ref if line.startswith("[SEND] %s" % label)]
if len(values):
print("%s %9.2f MiB (%10d bytes)" % ((label + ":").ljust(20, " "), values[0]/1024/1024, values[0]))
return values[0]
return 0
csv_fieldnames_time = ['g', 'total', 'total_stdev']
csv_fieldnames_mem = ['g', 'total']
print("Writing mem_UC.csv...")
with open("mem_UC.csv", 'w') as file_mem_csv, open("time_UC.csv", 'w') as file_time_csv:
csv_mem = csv.DictWriter(file_mem_csv, fieldnames=csv_fieldnames_mem)
csv_mem.writeheader()
csv_time = csv.DictWriter(file_time_csv, fieldnames=csv_fieldnames_time)
csv_time.writeheader()
for g in [100, 1000, 10000, 100000]:
print("\n\nPerformance stats for g = %d gates" % g)
if (not os.path.isfile("%s_SERVER_%s" % (file_prefix, g))):
print("%s_SERVER_%s does not exist" % (file_prefix, g))
continue
if (not os.path.isfile("%s_CLIENT_%s" % (file_prefix, g))):
print("%s_CLIENT_%s does not exist" % (file_prefix, g))
continue
with open("%s_SERVER_%s" % (file_prefix, g)) as file_server, open("%s_CLIENT_%s" % (file_prefix, g)) as file_client:
detected_runs_s = len([line for line in file_server if line.startswith("Evaluating Universal circuit in Yao Sharing")])
detected_runs_c = len([line for line in file_client if line.startswith("Evaluating Universal circuit in Yao Sharing")])
print("Detected number of runs: %d (SERVER), %d (CLIENT)" % (detected_runs_s, detected_runs_c))
if (detected_runs_s == 0 or detected_runs_c == 0):
continue
file_server.seek(0)
time_total_s = statistics.mean([float(line.split()[4]) for line in file_server if line.startswith("Total time / comm")])
file_client.seek(0)
time_total_c = statistics.mean([float(line.split()[4]) for line in file_client if line.startswith("Total time / comm")])
print("\n[S/C] Total time: %.2f ms / %.2f ms" % (time_total_s, time_total_c))
file_server.seek(0)
time_total_s_stdev = statistics.stdev([float(line.split()[4]) for line in file_server if line.startswith("Total time / comm")])
file_client.seek(0)
time_total_c_stdev = statistics.stdev([float(line.split()[4]) for line in file_client if line.startswith("Total time / comm")])
csv_time.writerow({'g': g, 'total': time_total_c, 'total_stdev': time_total_c_stdev})
### Communication
file_client.seek(0)
mem_total_c = [int(line.split()[7]) for line in file_client if line.startswith("Total time / comm")][0]
print("\nTotal communication: %.2f MiB" % (mem_total_c /1024/1024))
csv_mem.writerow({'g': g, 'total': mem_total_c})