Skip to content

Commit 836f8a8

Browse files
committed
Added a new plotter script.
1 parent f8a6563 commit 836f8a8

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/python3
2+
3+
# Copyright 2015-2017 Francisco Pina Martins <[email protected]>
4+
# This file is part of speedup_plotter.
5+
# speedup_plotter is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation, either version 3 of the License, or
8+
# (at your option) any later version.
9+
10+
# speedup_plotter is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
15+
# You should have received a copy of the GNU General Public License
16+
# along with speedup_plotter. If not, see <http://www.gnu.org/licenses/>.
17+
18+
import matplotlib.pyplot as plt
19+
import numpy
20+
21+
def data_harverster(datafile_name):
22+
"""
23+
Gather speedup data from a csv file and return a np array with it.
24+
"""
25+
timearray = numpy.genfromtxt(datafile_name, delimiter=";", autostrip=True,
26+
dtype=float, skip_header=False, names=True,
27+
filling_values=False)
28+
29+
return timearray
30+
31+
32+
def draw_plot(timearray):
33+
"""
34+
Draw a line plot based on speedup data.
35+
"""
36+
system_cores = max(map(int, timearray["CPUs"]))
37+
names = [x for x in timearray.dtype.names if x != "CPUs"]
38+
linetypes = ("k-", "k:", "k--")
39+
lines = {k: v for k, v in zip(names, linetypes)}
40+
plt.axis([1, system_cores + 1, 1, system_cores + 1])
41+
for name in names:
42+
plt.plot(list(map(int, timearray["CPUs"])), timearray[name],
43+
lines[name],
44+
fillstyle="full", ms=7, label=name)
45+
plt.plot(range(1, system_cores + 2), range(1, system_cores + 2), 'k-.',
46+
label="Linear scaling")
47+
48+
plt.grid(True)
49+
plt.xlabel("Number of threads")
50+
plt.ylabel("Speed increase")
51+
plt.xticks(list(map(int, timearray["CPUs"])))
52+
plt.legend(loc=2, fontsize="small")
53+
plt.savefig(argv[1] + "_plot.svg", format="svg")
54+
#plt.show()
55+
56+
if __name__ == "__main__":
57+
from sys import argv
58+
TIMEARRAY = data_harverster(argv[1])
59+
draw_plot(TIMEARRAY)

0 commit comments

Comments
 (0)