-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrite_csv.py
189 lines (159 loc) · 5.87 KB
/
write_csv.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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#!/usr/bin/env python3
import os
import sys
import csv
import json
import time
import copy
import logging
import pathlib
import argparse
import subprocess
from pathlib import Path
from threading import Thread, Timer
from datetime import datetime
from typing import Dict, Iterator, List, Optional, Text, DefaultDict, Any, IO, Callable
# from matplotlib import pyplot as plt
def average(lst):
return round(sum(lst) / len(lst), 2)
def process_6_1(input_filename, output_filename):
dic = {}
dic_rdma = {}
with open(input_filename, 'r') as file:
csv_reader = csv.reader(file, delimiter=',')
for row in csv_reader:
if "rdma" not in row[1]:
key = row[0]
if key not in dic:
dic[key] = dict.fromkeys(["Host", "Coyote", "vFPIO"], "")
dic[key][row[1]] = list(map(float, row[2:]))
else:
dic[key][row[1]] += list(map(float, row[2:]))
else:
tag = row[1].split("_")[1]
key = " " + row[0] + " "
if key not in dic_rdma:
dic_rdma[key] = dict.fromkeys(["Host", "Coyote", "vFPIO"], "")
dic_rdma[key][tag] = list(map(float, row[2:]))
else:
dic_rdma[key][tag] += list(map(float, row[2:]))
# print(dic)
# print(dic_rdma)
with open(output_filename, 'w') as file:
csv_writer = csv.writer(file)
csv_writer.writerow(["app", "throughput", "platform"])
for key in dic:
for platform in dic[key]:
out = [key, average(dic[key][platform]), platform]
csv_writer.writerow(out)
for key in dic_rdma:
for platform in dic_rdma[key]:
out = [key, average(dic_rdma[key][platform]), platform]
csv_writer.writerow(out)
print("write finished")
def process_6_4_cycle(input_filename, output_filename):
dic = {}
with open(input_filename, 'r') as file:
csv_reader = csv.reader(file, delimiter=',')
for row in csv_reader:
key = row[0]
if not row:
continue
if key not in dic:
dic[key] = list(map(float, row[1:]))
else:
dic[key] += list(map(float, row[1:]))
print(dic)
with open(output_filename, 'w') as file:
csv_writer = csv.writer(file)
csv_writer.writerow(["priority", "cycle"])
for key in dic:
out = [key, average(dic[key])]
csv_writer.writerow(out)
print("write finished")
def process_6_4_cntx(input_filename, output_filename):
dic = {}
with open(input_filename, 'r') as file:
csv_reader = csv.reader(file, delimiter=',')
for row in csv_reader:
if not row:
continue
key = (row[0], row[2])
if key not in dic:
dic[key] = [float(row[1])]
else:
dic[key] += [float(row[1])]
# print(dic)
with open(output_filename, 'w') as file:
csv_writer = csv.writer(file)
csv_writer.writerow(["size", "count", "platform"])
for key in dic:
out = [key[0], average(dic[key]), key[1]]
csv_writer.writerow(out)
print("write finished")
def process_6_4(input_filename, output_filename):
dic = {}
with open(input_filename, 'r') as file:
csv_reader = csv.reader(file, delimiter=',')
for row in csv_reader:
# print(row)
if not row:
continue
key = (row[0], row[2])
if key not in dic:
dic[key] = [float(row[1])]
else:
dic[key] += [float(row[1])]
# print(dic)
with open(output_filename, 'w') as file:
csv_writer = csv.writer(file)
csv_writer.writerow(["Size[KiB]", "Cycle", "Platform"])
for key in dic:
out = [key[0], average(dic[key]), key[1]]
csv_writer.writerow(out)
print("write finished")
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--reprogram", "-r", action="store_true",
help="reprogram fpga before running experiments")
parser.add_argument("--experiments", "-e", type=str, default="simple", help="select the experiments to run")
args = parser.parse_args()
reprogram = args.reprogram
exp = args.experiments
if exp == "6_1":
input_file = "results_6_1.csv"
output_file = "e2e.csv"
print("Running 6_1 example.")
process_6_1(input_file, output_file)
print("exp result path: " + output_file)
elif exp == "6_4_cycle":
input_file = "results_6_4_cycle.csv"
output_file = "performance_isolation.csv"
print("Running 6_4_cycle example.")
process_6_4_cycle(input_file, output_file)
print("exp result path: " + output_file)
elif exp == "6_4_cntx":
input_file = "results_6_4_cntx.csv"
output_file = "context_switch.csv"
print("Running 6_4_cntx example.")
process_6_4_cntx(input_file, output_file)
print("exp result path: " + output_file)
elif exp == "6_4_host":
input_file = "results_6_4_host.csv"
output_file = "performance_overhead_perf_host.csv"
print("Running 6_4_host example.")
process_6_4(input_file, output_file)
print("exp result path: " + output_file)
elif exp == "6_4_fpga":
input_file = "results_6_4_fpga.csv"
output_file = "performance_overhead_perf_fpga.csv"
print("Running 6_4_fpga example.")
process_6_4(input_file, output_file)
print("exp result path: " + output_file)
else:
print("No evaluation selected.")
print("--------------------------------------------")
# parse_output("LICENSE.md")
print("Finished")
if __name__ == "__main__":
main()