Commit f6024415 authored by Shukai Wang's avatar Shukai Wang
Browse files

fixed style, flexible input length

parent 81c6ec61
......@@ -57,9 +57,15 @@ def create_timelines(report):
def create_monitoring(report):
result = []
combined_monitoring_time = np.zeros((36,1))
combined_monitoring_cpu = np.zeros((36,1))
combined_monitoring_mem = np.zeros((36,1))
minlength = 3000000
# finding the shared (minimum length) part of the data
for worker in report.worker_list:
length = len(worker.monitoring.time)
if length < minlength:
minlength = length
combined_tim = np.zeros((minlength, 1))
combined_cpu = np.zeros((minlength, 1))
combined_mem = np.zeros((minlength, 1))
for worker in report.worker_list:
f = figure(plot_width=1000, plot_height=330,
x_range=[0, report.end_time],
......@@ -69,19 +75,10 @@ def create_monitoring(report):
f.line(worker.monitoring.time, worker.monitoring.mem,
color="red", legend="mem %")
# print("time")
# print(len(worker.monitoring.time))
current_time = worker.monitoring.time[0:36]
current_cpu = worker.monitoring.cpu[0:36]
current_mem = worker.monitoring.mem[0:36]
combined_monitoring_time = np.column_stack((combined_monitoring_time,current_time))
combined_monitoring_cpu = np.column_stack((combined_monitoring_cpu,current_cpu))
combined_monitoring_mem = np.column_stack((combined_monitoring_mem,current_mem))
# print(combined_monitoring_cpu)
avg_monitoring_mem = np.mean(worker.monitoring.mem)
# combine the time, cpu, memory into a 2D array respectively
combined_tim = np.column_stack((combined_tim, worker.monitoring.time))
combined_cpu = np.column_stack((combined_cpu, worker.monitoring.cpu))
combined_mem = np.column_stack((combined_mem, worker.monitoring.mem))
avg_monitoring_cpu = np.mean(worker.monitoring.cpu)
avg_monitoring_mem = np.mean(worker.monitoring.mem)
f.line(worker.monitoring.time, avg_monitoring_cpu,
......@@ -89,24 +86,24 @@ def create_monitoring(report):
f.line(worker.monitoring.time, avg_monitoring_mem,
color="green", legend="avg_mem %")
result.append([f])
combined_monitoring_time = combined_monitoring_time[:,1:]
combined_monitoring_cpu = combined_monitoring_cpu[:,1:]
combined_monitoring_mem = combined_monitoring_mem[:,1:]
avg_combined_monitoring_time = combined_monitoring_time.mean(axis=1)
avg_combined_monitoring_cpu = combined_monitoring_cpu.mean(axis=1)
avg_combined_monitoring_mem = combined_monitoring_mem.mean(axis=1)
# delete the first column, which is a list of zeros
combined_tim = combined_tim[:, 1:]
combined_cpu = combined_cpu[:, 1:]
combined_mem = combined_mem[:, 1:]
# take the mean of each row
avg_combined_tim = combined_tim.mean(axis=1)
avg_combined_cpu = combined_cpu.mean(axis=1)
avg_combined_mem = combined_mem.mean(axis=1)
# plot the average graph
f = figure(plot_width=1000, plot_height=330,
x_range=[0, report.end_time],
title="Worker_avg {}".format(worker.address))
f.line(avg_combined_monitoring_time, avg_combined_monitoring_cpu,
title="Avg_Worker {}".format(worker.address))
f.line(avg_combined_tim, avg_combined_cpu,
color="blue", legend="avg_CPU %")
f.line(avg_combined_monitoring_time, avg_combined_monitoring_mem,
f.line(avg_combined_tim, avg_combined_mem,
color="red", legend="avg_mem %")
result.append([f])
# print(avg_combined_monitoring_cpu)
return gridplot(result)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment