-
Notifications
You must be signed in to change notification settings - Fork 0
/
driver.py
executable file
·99 lines (78 loc) · 2.75 KB
/
driver.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
import os
import pandas as pd
import matplotlib.pyplot as plt
import csv
import shutil as util
import time
import random
Analyze_folder = "Analysis"
final_file = 'final.csv'
analyze_file = 'temp.csv'
Output_folder = "output_vr_rev"
TotalTests = 10
def run():
# Here we do multiple runs with varying values of r, d, w, tp and tl and report the observations in the form
# of both csv and plots.
algorithm = "vr_revisited_new.da"
output_file = Output_folder + "/" + "validation.csv"
output_heading = ['Num Clients', 'Max failures', 'Num of Req/Client' ,'C_Timeout','R_Timeout','Liveness', 'Correctness', 'Avg Latency', 'Exec Time', 'WallClock Time(ms)']
dataframe = pd.DataFrame(columns = output_heading)
df_list = []
# with open(output_file, mode='w+') as file:
# writer = csv.writer(file)
# writer.writerow(output_heading)
f = 2
c = 3
req = 5
c_tout = 10
r_tout = 5
c = random.sample(range(1, 50),TotalTests)
for testNum in range(1,TotalTests+1):
# c = random.randint(1,10)
# req = random.randint(1,10)
# c_tout = random.randint(10,20)
# r_tout = random.randint(5,c_tout)
headings = ['Correctness', 'Avg Latency', 'Exec Time', 'WallClock Time(ms)']
with open(analyze_file, mode='a') as file:
writer = csv.writer(file)
writer.writerow(headings)
cmd = str('python -m da' + " " + algorithm + " " + str(f) + " " + str(c[testNum-1]) + " " + str(req) + " " + str(c_tout) + " " + str(r_tout))
os.system(cmd)
print("Done Analyzing")
df = pd.read_csv(analyze_file, nrows=None)
isCorrect = "True" if df['Correctness'].astype(int).sum() > 0 else 0
isLive = "True"
avg_latency = df['Avg Latency'].sum()
exec_time = df['Exec Time'].sum()
wallclock = df['WallClock Time(ms)'].sum()
output_row = [c[testNum-1], f, req, c_tout, r_tout, isLive, isCorrect, avg_latency, exec_time, wallclock]
df_list.append(output_row)
# with open(output_file, mode='a') as file:
# writer = csv.writer(file)
# writer.writerow(output_row)
del df
os.remove(analyze_file)
dataframe = pd.DataFrame(df_list, columns= output_heading)
dataframe = dataframe.sort_values('Num Clients')
dataframe.to_csv(output_file)
print(dataframe.head(TotalTests))
x = dataframe['Num Clients']
y = dataframe['Exec Time']
y1 = dataframe['Avg Latency']
plt.plot(x,y, linewidth=2.0, label="Exec. Time")
plt.plot(x, y1, linewidth= 1.0, label="Avg Latency")
plt.xlabel('Num Clients')
plt.ylabel('time')
plt.title('Performance Analysis with Num Clients')
plt.legend(loc='upper left')
plt.show()
if __name__ == "__main__":
if os.path.exists(Analyze_folder):
util.rmtree(Analyze_folder)
if os.path.exists(Output_folder):
util.rmtree(Output_folder)
if os.path.exists(analyze_file):
os.remove(analyze_file)
os.mkdir(Analyze_folder)
os.mkdir(Output_folder)
run()