Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate from python2 to python3 #22

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions PAT-post-processing/cpu_module.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3
#
# Copyright (c) 2015, Intel Corporation
#
Expand Down Expand Up @@ -497,7 +497,7 @@ def write_excel(cluster, wb):
def csv_writer(cluster, csv_path_cpu):
"""write data to a CSV file path"""

csv_file = open(csv_path_cpu, "wb")
csv_file = open(csv_path_cpu, "w")
for node in cluster:
if hasattr(node, 'cpu_obj'):
node_data = node.cpu_obj.data_array
Expand Down
109 changes: 66 additions & 43 deletions PAT-post-processing/disk_module.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3
#
# Copyright (c) 2015, Intel Corporation
#
Expand Down Expand Up @@ -55,8 +55,9 @@ def extract_data(self):
self.ts_index = self.title_line.index("TimeStamp")
self.rkbps_index = self.title_line.index("rkB/s")
self.wkbps_index = self.title_line.index("wkB/s")
self.await_index = self.title_line.index("await")
self.svctm_index = self.title_line.index("svctm")
self.r_await_index = self.title_line.index("r_await")
self.w_await_index = self.title_line.index("w_await")
self.util_index = self.title_line.index("%util")
del self.data_array[0]

self.time_stamp_array = []
Expand All @@ -68,15 +69,17 @@ def extract_data(self):
self.wps = []
self.rkbps = []
self.wkbps = []
self.await = []
self.svctm = []
self.r_await = []
self.w_await = []
self.util = []
for self.row in self.data_array:
self.rps.append(float(self.row[self.rps_index]))
self.wps.append(float(self.row[self.wps_index]))
self.rkbps.append(float(self.row[self.rkbps_index]))
self.wkbps.append(float(self.row[self.wkbps_index]))
self.await.append(float(self.row[self.await_index]))
self.svctm.append(float(self.row[self.svctm_index]))
self.r_await.append(float(self.row[self.r_await_index]))
self.w_await.append(float(self.row[self.w_await_index]))
self.util.append(float(self.row[self.util_index]))

self.ts_sum = []
self.avg_ind = 0
Expand Down Expand Up @@ -105,11 +108,14 @@ def extract_data(self):
self.rkbps_sum = self.get_sum(self.rkbps_index, self.rkbps)
self.avg_array.append(self.rkbps_sum)

self.await_sum = self.get_sum(self.await_index, self.await)
self.avg_array.append(self.await_sum)
self.r_await_sum = self.get_sum(self.r_await_index, self.r_await)
self.avg_array.append(self.r_await_sum)

self.svctm_sum = self.get_sum(self.svctm_index, self.svctm)
self.avg_array.append(self.svctm_sum)
self.w_await_sum = self.get_sum(self.w_await_index, self.w_await)
self.avg_array.append(self.w_await_sum)

self.util_sum = self.get_sum(self.util_index, self.util)
self.avg_array.append(self.util_sum)

self.data_array.insert(0, self.title_line)
return self.avg_array
Expand Down Expand Up @@ -138,8 +144,9 @@ def get_avg_data(cluster, name_node):
rps_dic = {}
wkbps_dic = {}
rkbps_dic = {}
await_dic = {}
svctm_dic = {}
r_await_dic = {}
w_await_dic = {}
util_dic = {}
count_dic = {}

for node in cluster:
Expand All @@ -164,14 +171,18 @@ def get_avg_data(cluster, name_node):
rkbps += node.disk_obj.avg_array[4][index]
rkbps_dic.update(dict([(node.disk_obj.ts_sum[index],
rkbps)]))
await = await_dic.get(node.disk_obj.ts_sum[index])
await += node.disk_obj.avg_array[5][index]
await_dic.update(dict([(node.disk_obj.ts_sum[index],
await)]))
svctm = svctm_dic.get(node.disk_obj.ts_sum[index])
svctm += node.disk_obj.avg_array[6][index]
svctm_dic.update(dict([(node.disk_obj.ts_sum[index],
svctm)]))
r_await = r_await_dic.get(node.disk_obj.ts_sum[index])
r_await += node.disk_obj.avg_array[5][index]
r_await_dic.update(dict([(node.disk_obj.ts_sum[index],
r_await)]))
w_await = w_await_dic.get(node.disk_obj.ts_sum[index])
w_await += node.disk_obj.avg_array[6][index]
w_await_dic.update(dict([(node.disk_obj.ts_sum[index],
w_await)]))
util = util_dic.get(node.disk_obj.ts_sum[index])
util += node.disk_obj.avg_array[7][index]
util_dic.update(dict([(node.disk_obj.ts_sum[index],
util)]))
cnt = count_dic.get(node.disk_obj.ts_sum[index])
cnt += 1
count_dic.update(dict([(node.disk_obj.ts_sum[
Expand All @@ -185,10 +196,12 @@ def get_avg_data(cluster, name_node):
index], node.disk_obj.avg_array[3][index])]))
rkbps_dic.update(dict([(node.disk_obj.ts_sum[
index], node.disk_obj.avg_array[4][index])]))
await_dic.update(dict([(node.disk_obj.ts_sum[
r_await_dic.update(dict([(node.disk_obj.ts_sum[
index], node.disk_obj.avg_array[5][index])]))
svctm_dic.update(dict([(node.disk_obj.ts_sum[
w_await_dic.update(dict([(node.disk_obj.ts_sum[
index], node.disk_obj.avg_array[6][index])]))
util_dic.update(dict([(node.disk_obj.ts_sum[
index], node.disk_obj.avg_array[7][index])]))
count_dic.update(dict([(node.disk_obj.ts_sum[
index], 1)]))

Expand All @@ -198,15 +211,17 @@ def get_avg_data(cluster, name_node):
wps = wps_dic.values()
rkbps = rkbps_dic.values()
wkbps = wkbps_dic.values()
await = await_dic.values()
svctm = svctm_dic.values()
r_await = r_await_dic.values()
w_await = w_await_dic.values()
util = util_dic.values()
count = count_dic.values()
rps = [x for y, x in sorted(zip(ts, rps))]
wps = [x for y, x in sorted(zip(ts, wps))]
rkbps = [x for y, x in sorted(zip(ts, rkbps))]
wkbps = [x for y, x in sorted(zip(ts, wkbps))]
await = [x for y, x in sorted(zip(ts, await))]
svctm = [x for y, x in sorted(zip(ts, svctm))]
r_await = [x for y, x in sorted(zip(ts, r_await))]
w_await = [x for y, x in sorted(zip(ts, w_await))]
util = [x for y, x in sorted(zip(ts, util))]
count = [x for y, x in sorted(zip(ts, count))]
ts = sorted(ts)

Expand All @@ -218,11 +233,13 @@ def get_avg_data(cluster, name_node):
wkbps[index] = row / count[index]
for index, row in enumerate(rkbps):
rkbps[index] = row / count[index]
for index, row in enumerate(await):
await[index] = row / count[index]
for index, row in enumerate(svctm):
svctm[index] = row / count[index]
avg_array = [ts, wps, rps, wkbps, rkbps, await, svctm]
for index, row in enumerate(r_await):
r_await[index] = row / count[index]
for index, row in enumerate(w_await):
w_await[index] = row / count[index]
for index, row in enumerate(util):
util[index] = row / count[index]
avg_array = [ts, wps, rps, wkbps, rkbps, r_await, w_await, util]
return avg_array
else:
return None
Expand Down Expand Up @@ -305,9 +322,11 @@ def plot_graph(data, pp, graph_title):
fig.text(0.14, 0.89, fig_caption, fontsize=10,
horizontalalignment='left', verticalalignment='top')
# plot graphs
ax.plot(x, data[5], label='await',
ax.plot(x, data[5], label='r_await',
color='#00297A', alpha=0.9, linewidth=0.5, rasterized=True)
ax.plot(x, data[6], label='svctm',
ax.plot(x, data[5], label='w_await',
color='#004f7a', alpha=0.9, linewidth=0.5, rasterized=True)
ax.plot(x, data[6], label='util',
color='#800000', alpha=0.9, linewidth=0.5, rasterized=True)
ax.fill_between(x, 0, data[5], facecolor='#00297A',
alpha=0.45, linewidth=0.01, rasterized=True)
Expand Down Expand Up @@ -351,16 +370,20 @@ def get_data_for_graph(data_array):
for entry in data_array[4]:
rkbps.append(float(entry))
new_rkbps = get_graph_mean(x, rkbps)
await = []
r_await = []
for entry in data_array[5]:
await.append(float(entry))
new_await = get_graph_mean(x, await)
svctm = []
r_await.append(float(entry))
new_r_await = get_graph_mean(x, r_await)
w_await = []
for entry in data_array[6]:
svctm.append(float(entry))
new_svctm = get_graph_mean(x, svctm)
return [new_ts, new_wps, new_rps, new_wkbps, new_rkbps, new_await,
new_svctm], x
w_await.append(float(entry))
new_w_await = get_graph_mean(x, w_await)
util = []
for entry in data_array[7]:
util.append(float(entry))
new_util = get_graph_mean(x, util)
return [new_ts, new_wps, new_rps, new_wkbps, new_rkbps, new_r_await, new_w_await,
new_util], x
else:
return data_array, x

Expand Down Expand Up @@ -441,7 +464,7 @@ def write_excel(cluster, wb):
def csv_writer(cluster, csv_path_disk):
"""write data to a CSV file path"""

csv_file = open(csv_path_disk, "wb")
csv_file = open(csv_path_disk, "w")
for node in cluster:
if hasattr(node, 'disk_obj'):
node_data = node.disk_obj.data_array
Expand Down
4 changes: 2 additions & 2 deletions PAT-post-processing/memory_module.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3
#
# Copyright (c) 2015, Intel Corporation
#
Expand Down Expand Up @@ -378,7 +378,7 @@ def write_excel(cluster, wb):
def csv_writer(cluster, csv_path_memory):
"""write data to a CSV file path"""

csv_file = open(csv_path_memory, "wb")
csv_file = open(csv_path_memory, "w")
for node in cluster:
if hasattr(node, 'memory_obj'):
node_data = node.memory_obj.data_array
Expand Down
4 changes: 2 additions & 2 deletions PAT-post-processing/net_module.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/python3
#
# Copyright (c) 2015, Intel Corporation
#
Expand Down Expand Up @@ -316,7 +316,7 @@ def write_excel(cluster, wb):
def csv_writer(cluster, csv_path_net):
"""write data to a CSV file path"""

csv_file = open(csv_path_net, "wb")
csv_file = open(csv_path_net, "w")
for node in cluster:
if hasattr(node, 'net_obj'):
node_data = node.net_obj.data_array
Expand Down
Loading