Skip to content
This repository was archived by the owner on Jan 9, 2024. It is now read-only.

Commit bea88d0

Browse files
authored
Improvements in perf test runner (#40)
1 parent 4e75321 commit bea88d0

File tree

1 file changed

+37
-8
lines changed

1 file changed

+37
-8
lines changed

tests/perf/run_perf_tests.py

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,13 @@ def __init__(self, test_report, config):
8181
self.config = config
8282
self.rpc_daemon = 0
8383
self.silk_daemon = 0
84+
self.stop_silk_daemon()
8485
self.stop_rpc_daemon()
86+
print("\nSetup temporary daemon to verify configuration is OK")
87+
self.start_silk_daemon()
8588
self.stop_silk_daemon()
89+
self.start_rpc_daemon()
90+
self.stop_rpc_daemon()
8691
self.copy_pattern_file()
8792

8893
def copy_pattern_file(self):
@@ -104,8 +109,15 @@ def start_rpc_daemon(self):
104109
cmd = "taskset -c " + self.config.daemon_on_core + " " + \
105110
self.config.geth_homedir + "build/bin/rpcdaemon --private.api.addr="+self.config.tg_addr+" --http.api=eth,debug,net,web3 &"
106111
print("RpcDaemon starting ...: ", cmd)
107-
os.system(cmd)
112+
status = os.system(cmd)
113+
if int(status) != 0:
114+
print("Start rpc daemon failed: Test Aborted!")
115+
sys.exit(-1)
108116
os.system("sleep 1")
117+
pid = os.popen("ps aux | grep 'rpcdaemon' | grep -v 'grep' | awk '{print $2}'").read()
118+
if pid == "":
119+
print("Start rpc daemon failed: Test Aborted!")
120+
sys.exit(-1)
109121

110122
def stop_rpc_daemon(self):
111123
""" Stops the RPC daemon server
@@ -125,8 +137,15 @@ def start_silk_daemon(self):
125137
cmd = "taskset -c " + self.config.daemon_on_core + \
126138
" ../../build_gcc_release/silkrpc/silkrpcdaemon --target "+self.config.tg_addr+" --local localhost:51515 --logLevel c &"
127139
print("SilkDaemon starting ...: ", cmd)
128-
os.system(cmd)
140+
status = os.system(cmd)
141+
if int(status) != 0:
142+
print("Start silkrpc daemon failed: Test Aborted!")
143+
sys.exit(-1)
129144
os.system("sleep 1")
145+
pid = os.popen("ps aux | grep 'silkrpc' | grep -v 'grep' | awk '{print $2}'").read()
146+
if pid == "":
147+
print("Start silkrpc daemon failed: Test Aborted!")
148+
sys.exit(-1)
130149

131150
def stop_silk_daemon(self):
132151
""" Stops SILKRPC daemon
@@ -141,7 +160,8 @@ def execute(self, test_number, name, qps_value, time_value):
141160
""" Executes the tests using qps and time variable
142161
"""
143162
script_name = "./vegeta_attack_getLogs_"+name+".sh" +" "+str(qps_value) + " " + str(time_value)
144-
print(test_number+" "+name+": executes test qps:", str(qps_value) + " time:"+str(time_value))
163+
print(test_number+" "+name+": executes test qps:", str(qps_value) + " time:"+str(time_value)+" -> ", end="")
164+
sys.stdout.flush()
145165
os.system(script_name)
146166
self.get_result(test_number, name, qps_value, time_value)
147167

@@ -159,7 +179,8 @@ def get_result(self, test_number, daemon_name, qps_value, time_value):
159179
max_latency = latency_values[12]
160180
newline = file_raws[5].replace('\n', ' ')
161181
ratio = newline.split(' ')[34]
162-
threads = os.popen("ps -efL | grep tg | wc -l").read().replace('\n', ' ')
182+
print(" [ Ratio="+ratio+", MaxLatency="+max_latency+"]")
183+
threads = os.popen("ps -efL | grep tg | grep bin | wc -l").read().replace('\n', ' ')
163184
finally:
164185
file.close()
165186

@@ -182,7 +203,7 @@ def __init__(self, config):
182203
def open(self):
183204
""" Writes on CVS file the header
184205
"""
185-
csv_filename = datetime.today().strftime('%Y-%m-%d-%H:%M:%S')+"_perf.csv"
206+
csv_filename = "/tmp/" + datetime.today().strftime('%Y-%m-%d-%H:%M:%S')+"_perf.csv"
186207
self.csv_file = open(csv_filename, 'w', newline='')
187208
self.writer = csv.writer(self.csv_file)
188209

@@ -194,6 +215,12 @@ def open(self):
194215
command = "gcc --version"
195216
gcc_vers = os.popen(command).read().split(',')
196217

218+
command = "go version"
219+
go_vers = os.popen(command).read().replace('\n', '')
220+
221+
command = "uname -r"
222+
kern_vers = os.popen(command).read().replace('\n', "").replace('\'', '')
223+
197224
command = "cat /proc/cpuinfo | grep 'model name' | uniq"
198225
model = os.popen(command).readline().replace('\n', ' ').split(':')
199226
command = "cat /proc/cpuinfo | grep 'bogomips' | uniq"
@@ -202,19 +229,20 @@ def open(self):
202229

203230
self.writer.writerow(["", "", "", "", "", "", "", "", "", "", "", "", "PC", model[1]])
204231
self.writer.writerow(["", "", "", "", "", "", "", "", "", "", "", "", "Bogomips", bogomips])
232+
self.writer.writerow(["", "", "", "", "", "", "", "", "", "", "", "", "Kernel", kern_vers])
205233
self.writer.writerow(["", "", "", "", "", "", "", "", "", "", "", "", "DaemonRunOnCore", self.config.daemon_on_core])
206234
self.writer.writerow(["", "", "", "", "", "", "", "", "", "", "", "", "TG address", self.config.tg_addr])
207235
self.writer.writerow(["", "", "", "", "", "", "", "", "", "", "", "", "VegetaFile", self.config.vegeta_pattern_tar_file])
208236
self.writer.writerow(["", "", "", "", "", "", "", "", "", "", "", "", "VegetaChecksum", checksum[0]])
209237
self.writer.writerow(["", "", "", "", "", "", "", "", "", "", "", "", "GccVers", gcc_vers[0]])
238+
self.writer.writerow(["", "", "", "", "", "", "", "", "", "", "", "", "GoVers", go_vers])
210239
self.writer.writerow(["", "", "", "", "", "", "", "", "", "", "", "", "SilkVersion", "master"])
211240
self.writer.writerow(["", "", "", "", "", "", "", "", "", "", "", "", "RpcDaemon", "master"])
212241
self.writer.writerow([])
213242
self.writer.writerow([])
214243
self.writer.writerow(["Daemon", "TestNo", "TG-Threads", "Qps", "Time", "Min", "Mean", "50", "90", "95", "99", "Max", "Ratio"])
215244
self.csv_file.flush()
216245

217-
218246
def write_test_report(self, daemon, test_number, threads, qps_value, time_value, min_latency, mean, fifty, ninty, nintyfive, nintynine, max_latency, ratio):
219247
""" Writes on CVS the latency data for one completed test
220248
"""
@@ -252,7 +280,7 @@ def main(argv):
252280
for test_rep in range(0, config.repetitions):
253281
qps = test.split(':')[0]
254282
time = test.split(':')[1]
255-
perf_test.execute(str(test_number)+"."+str(test_rep+1), "silkrpc", qps, time)
283+
perf_test.execute("["+str(test_number)+"."+str(test_rep+1)+"] ", "silkrpc", qps, time)
256284
os.system("sleep 1")
257285
test_number = test_number + 1
258286
print("")
@@ -267,13 +295,14 @@ def main(argv):
267295
for test_rep in range(0, config.repetitions):
268296
qps = test.split(':')[0]
269297
time = test.split(':')[1]
270-
perf_test.execute(str(test_number)+"."+str(test_rep+1), "rpcdaemon", qps, time)
298+
perf_test.execute("["+str(test_number)+"."+str(test_rep+1)+"] ", "rpcdaemon", qps, time)
271299
os.system("sleep 1")
272300
test_number = test_number + 1
273301
print("")
274302

275303
perf_test.stop_rpc_daemon()
276304
test_report.close()
305+
print("Test Terminated successfully.")
277306

278307

279308
#

0 commit comments

Comments
 (0)