-
Notifications
You must be signed in to change notification settings - Fork 2
/
deal_time.py
142 lines (126 loc) · 5.1 KB
/
deal_time.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
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
import sys
import platform
import pandas as pd
pd.set_option('display.float_format', lambda x: '%.2f' % x)
plt.rc('xtick', labelsize=5) # fontsize of the tick labels
plt.rc('ytick', labelsize=10) # fontsize of the tick labels
plt.rc('legend', fontsize=10) # fontsize of the tick labels
def to_table(file_name):
system = str(platform.platform())
test_names = []
method_names = []
all_datas = {}
f = open(file_name)
for line in f:
splitted = line.strip().split(",")
test_name = ",".join(splitted[1:-3])
# print(test_name)
method_name = splitted[-3].replace(" METHOD", "")
raw_time = float(splitted[-2].split("us")[0])/1000
fraction = splitted[-1].split("x")[0]
if (not test_name in all_datas):
all_datas[test_name] = {}
test_names.append(test_name)
if (not method_name in method_names):
method_names.append(method_name)
all_datas[test_name][method_name] = [float(raw_time), float(fraction)]
print("Raw timing on %s: " % system)
raw_datas = {}
for test in test_names:
# print(test)
raw_datas[test] = [all_datas[test][x][0] for x in method_names]
raw_datas_table = pd.DataFrame.from_dict(
raw_datas, orient='index', columns=method_names)
raw_datas_table = raw_datas_table.reindex(test_names)
print(raw_datas_table)
print(raw_datas_table.to_latex())
# print("Comparing to filib c version on %s: " % system)
# comp_datas = {}
# for test in test_names:
# comp_datas[test] = [all_datas[test][x][1] for x in method_names]
# comp_datas_table = pd.DataFrame.from_dict(
# comp_datas, orient='index', columns=method_names)
# comp_datas_table = comp_datas_table.reindex(test_names)
# print(comp_datas_table)
# print(comp_datas_table.to_latex())
def plot_table(file_name):
system = str(platform.platform())
test_names = []
method_names = []
all_datas = {}
f = open(file_name)
for line in f:
splitted = line.strip().split(",")
test_name = ",".join(splitted[1:-3]).strip()
# print(test_name)
if test_name.startswith("RANDOM") or test_name.startswith("ARITHMETIC"):
test_name = test_name.split()
test_name = test_name[0] + test_name[2]
# print(splitted)
method_name = splitted[-3].replace(" METHOD", "")
raw_time = float(splitted[-2].split("us")[0])/1000
fraction = splitted[-1].split("x")[0]
if (not test_name in all_datas):
all_datas[test_name] = {}
test_names.append(test_name)
if (not method_name in method_names):
method_names.append(method_name)
all_datas[test_name][method_name] = [float(raw_time), float(fraction)]
raw_datas = {}
for test in test_names:
raw_datas[test] = [all_datas[test][x][0] for x in method_names]
raw_datas_table = pd.DataFrame.from_dict(
raw_datas, orient='index', columns=method_names)
raw_datas_table = raw_datas_table.reindex(test_names)
comp_datas = {}
for test in test_names:
comp_datas[test] = [all_datas[test][x][1] for x in method_names]
comp_datas_table = pd.DataFrame.from_dict(
comp_datas, orient='index', columns=method_names)
comp_datas_table = comp_datas_table.reindex(test_names)
single_op_raw_time = raw_datas_table[0:8]
arith_comp_raw_time = raw_datas_table[8:18]
mix_comp_raw_time = raw_datas_table[18:28]
ax = single_op_raw_time.plot.bar(rot=0)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
save_plot_name = "graphs/time/" + "single_operations_time_" + system + ".pdf"
plt.savefig(save_plot_name, bbox_inches='tight',
pad_inches=0, dpi=400,)
plt.close()
ax = arith_comp_raw_time.plot.bar(rot=0)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
save_plot_name = "graphs/time/" + "comp_arith_time_" + system + ".pdf"
plt.savefig(save_plot_name, bbox_inches='tight',
pad_inches=0, dpi=400)
plt.close()
ax = mix_comp_raw_time.plot.bar(rot=0)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
save_plot_name = "graphs/time/" + "comp_all_time_" + system + ".pdf"
plt.savefig(save_plot_name, bbox_inches='tight',
pad_inches=0, dpi=400)
plt.close()
for i in range(28, 132, 4):
fpbench_raw_time = raw_datas_table[i:i+4]
# print(fpbench_raw_time)
ax = fpbench_raw_time.plot.bar(rot=0)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
save_plot_name = "graphs/time/" + "comp_fpbench_" + str(i-28) + "_" + str(i+4-28) + ".pdf"
plt.savefig(save_plot_name, bbox_inches='tight',
pad_inches=0, dpi=400)
plt.close()
def main():
if len(sys.argv) > 1:
to_table(sys.argv[1])
plot_table(sys.argv[1])
else:
to_table("build/time.txt")
plot_table("build/time.txt")
if __name__ == "__main__":
main()