forked from stanfordhpccenter/HTR-solver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
post.py
60 lines (51 loc) · 1.46 KB
/
post.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
#!/usr/bin/env python2
import argparse
import collections
import matplotlib.pyplot as plt
from matplotlib.ticker import FormatStrFormatter
parser = argparse.ArgumentParser()
parser.add_argument("-n", "--num_times", type=int, default=4)
parser.add_argument('-b', '--before', type=int, default=20)
parser.add_argument("-out", "--baseDir")
args = parser.parse_args()
def postFile(Dir):
lineno = 0
t_start = None
tail = collections.deque()
with open(Dir + "/sample0/console.txt", "r") as fout:
for line in fout:
lineno += 1
if lineno - 2 < args.before:
continue
t = float(line.split()[2])
if t_start is None:
t_start = t
tail.append(t)
assert t_start is not None
t_end = tail[-1]
return t_end - t_start
nodes = []
wt = []
for i in range(0,args.num_times):
nodes.append(int(2**i))
wt.append(postFile(args.baseDir + "/" + str(nodes[i])))
scale = wt[0]
optimal = []
speedup = []
for i in range(0,args.num_times):
optimal.append(int(2**i))
speedup.append(scale/wt[i])
print(nodes[i], wt[i], speedup[i])
plt.figure(1)
plt.plot(nodes, optimal, '--k', label="Optimal")
plt.plot(nodes, speedup, '-ok', label="Measured")
plt.xlabel(r"nodes")
plt.ylabel(r"speedup")
plt.xticks(nodes)
plt.minorticks_off()
plt.grid()
plt.legend()
plt.gca().xaxis.set_major_formatter(FormatStrFormatter('%d'))
#plt.gca().set_ylim(0.6, 1.05)
plt.savefig(args.baseDir+".eps", bbox_inches='tight')
plt.show()