1 |
commit: b92f48b60548d0be057bc9dbe264e00fc186227f |
2 |
Author: Andrea Arteaga <andyspiros <AT> gmail <DOT> com> |
3 |
AuthorDate: Fri Feb 24 17:58:34 2012 +0000 |
4 |
Commit: Andrea Arteaga <andyspiros <AT> gmail <DOT> com> |
5 |
CommitDate: Fri Feb 24 17:58:34 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=b92f48b6 |
7 |
|
8 |
New Plotter class |
9 |
|
10 |
--- |
11 |
blastests.xml | 3 + |
12 |
numbench/confinput/xmlinput.py | 2 +- |
13 |
numbench/htmlreport.py | 2 +- |
14 |
numbench/modules/internal/blasBase.py | 6 +-- |
15 |
numbench/modules/internal/btlBase.py | 2 +- |
16 |
numbench/report.py | 95 +++++++++++++++++++++------------ |
17 |
6 files changed, 68 insertions(+), 42 deletions(-) |
18 |
|
19 |
diff --git a/blastests.xml b/blastests.xml |
20 |
index 75f5ba4..d01615b 100644 |
21 |
--- a/blastests.xml |
22 |
+++ b/blastests.xml |
23 |
@@ -1,10 +1,13 @@ |
24 |
<tests> |
25 |
+ |
26 |
+<!-- |
27 |
<test id="reference"> |
28 |
<pkg>sci-libs/blas-reference-20120215-r1</pkg> |
29 |
<emergeenv> |
30 |
<var name="FFLAGS">-O3</var> |
31 |
</emergeenv> |
32 |
</test> |
33 |
+--> |
34 |
|
35 |
<!-- |
36 |
<test id="atlas"> |
37 |
|
38 |
diff --git a/numbench/confinput/xmlinput.py b/numbench/confinput/xmlinput.py |
39 |
index 2a145a9..4743730 100644 |
40 |
--- a/numbench/confinput/xmlinput.py |
41 |
+++ b/numbench/confinput/xmlinput.py |
42 |
@@ -105,7 +105,7 @@ def parseConf(fname): |
43 |
skip = [] |
44 |
skipre = [] |
45 |
for s in t.getElementsByTagName('skip'): |
46 |
- if not s.hasAtribute('type') or s.getAttribute('type') == 'glob': |
47 |
+ if not s.hasAttribute('type') or s.getAttribute('type') == 'glob': |
48 |
skip.append(s.firstChild.data) |
49 |
elif s.getAttribute('type') == 'regexp': |
50 |
skipre.append(s.firstChild.data) |
51 |
|
52 |
diff --git a/numbench/htmlreport.py b/numbench/htmlreport.py |
53 |
index 33c19fa..0439aff 100644 |
54 |
--- a/numbench/htmlreport.py |
55 |
+++ b/numbench/htmlreport.py |
56 |
@@ -91,7 +91,7 @@ h1, h2, .plot, .descr, .info { |
57 |
def addFig(self, title, image, descr='', alt='', width=None): |
58 |
self.content += '<div class="fig">' |
59 |
self.content += '<h2>' + title + '</h2>' |
60 |
- if descr.strip() != '': |
61 |
+ if descr.strip() != '': |
62 |
self.content += '<p class="descr">' + descr + '</p>' |
63 |
self.content += '<div class="plot">' |
64 |
self.content += '<a href="' + image + '">' |
65 |
|
66 |
diff --git a/numbench/modules/internal/blasBase.py b/numbench/modules/internal/blasBase.py |
67 |
index 5e691e3..cf8ba07 100644 |
68 |
--- a/numbench/modules/internal/blasBase.py |
69 |
+++ b/numbench/modules/internal/blasBase.py |
70 |
@@ -32,10 +32,6 @@ def init(self, args): |
71 |
passargs = [] |
72 |
tests = [] |
73 |
|
74 |
- if len(args) == 0: |
75 |
- self.tests = defaultTests |
76 |
- return |
77 |
- |
78 |
for i in args: |
79 |
if i == '1': |
80 |
tests += avail1 |
81 |
@@ -49,6 +45,8 @@ def init(self, args): |
82 |
passargs.append(i) |
83 |
|
84 |
self.tests = btl.selectTests(availableTests, passargs+tests) |
85 |
+ if len(self.tests) == 0: |
86 |
+ self.tests = defaultTests |
87 |
|
88 |
|
89 |
def getImplementations(self, test): |
90 |
|
91 |
diff --git a/numbench/modules/internal/btlBase.py b/numbench/modules/internal/btlBase.py |
92 |
index 3c33202..8237692 100644 |
93 |
--- a/numbench/modules/internal/btlBase.py |
94 |
+++ b/numbench/modules/internal/btlBase.py |
95 |
@@ -26,7 +26,7 @@ def reportConf(*args): |
96 |
def runTest(self, test, btlconfig): |
97 |
# Check if results already exist |
98 |
tmpres = dict( \ |
99 |
- [(i, pjoin(btlconfig['testdir'], "bench_"+i+"_"+self.libname)) \ |
100 |
+ [(i, pjoin(btlconfig['testdir'], 'bench_'+i+'_'+self.libname+'.dat')) \ |
101 |
for i in btlconfig['tests']]) |
102 |
|
103 |
if all([exists(i) for i in tmpres.values()]): |
104 |
|
105 |
diff --git a/numbench/report.py b/numbench/report.py |
106 |
index 901723b..75be5c4 100644 |
107 |
--- a/numbench/report.py |
108 |
+++ b/numbench/report.py |
109 |
@@ -16,7 +16,8 @@ |
110 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
111 |
# |
112 |
from os.path import join as pjoin, basename |
113 |
-import numpy as np |
114 |
+import sys, numpy as np |
115 |
+from shutil import rmtree |
116 |
|
117 |
import benchconfig as cfg |
118 |
import benchutils as bu |
119 |
@@ -24,8 +25,53 @@ from htmlreport import HTMLreport |
120 |
from testdescr import testdescr |
121 |
from benchprint import Print |
122 |
|
123 |
-def saveReport(): |
124 |
|
125 |
+class Plotter: |
126 |
+ def __init__(self, conf): |
127 |
+ # Set plot function |
128 |
+ self.conf = conf |
129 |
+ if not conf.has_key('type'): |
130 |
+ self.plotf = plt.plot |
131 |
+ elif type(conf['type']) == type(''): |
132 |
+ try: |
133 |
+ self.plotf = plt.__dict__[conf['type']] |
134 |
+ except: |
135 |
+ print >> sys.stderr, \ |
136 |
+ 'Plot function "', conf['type'], '" not found. Using plot' |
137 |
+ self.plotf = plt.plot |
138 |
+ return |
139 |
+ else: |
140 |
+ self.plot = conf['type'] |
141 |
+ |
142 |
+ # Labels |
143 |
+ self.xlabel = conf.has_key('xlabel') and conf['xlabel'] or '' |
144 |
+ self.ylabel = conf.has_key('ylabel') and conf['ylabel'] or '' |
145 |
+ |
146 |
+ # Initialize markers |
147 |
+ markers = ('-', '--', 'o', 'v', '^', 's', 'p', 'h', '*', '+', 'x', 'D') |
148 |
+ colors = ('k', 'r', 'g', 'b') |
149 |
+ self.linestyles = tuple([c+m for m in markers for c in colors]) |
150 |
+ self.curstyle = 0 |
151 |
+ |
152 |
+ # Open figure |
153 |
+ plt.figure(figsize=(12,9), dpi=300) |
154 |
+ |
155 |
+ |
156 |
+ def addPlot(self, x, y, label): |
157 |
+ style = self.linestyles[self.curstyle] |
158 |
+ self.curstyle = (self.curstyle+1) % len(self.linestyles) |
159 |
+ self.plotf(x, y, style, label=label, hold=True) |
160 |
+ |
161 |
+ def savePlot(self, fname): |
162 |
+ plt.legend(loc='best') |
163 |
+ plt.xlabel(self.xlabel) |
164 |
+ plt.ylabel(self.ylabel) |
165 |
+ plt.grid(True) |
166 |
+ plt.savefig(fname, format='png', bbox_inches='tight', transparent=True) |
167 |
+ |
168 |
+ |
169 |
+ |
170 |
+def saveReport(): |
171 |
# Check whether pyplot is working |
172 |
try: |
173 |
plt.figure() |
174 |
@@ -34,53 +80,32 @@ def saveReport(): |
175 |
Print("Please make sure that X is running and $DISPLAY is set") |
176 |
return |
177 |
|
178 |
- # Read configuration |
179 |
- conf = cfg.mod.reportConf() |
180 |
- |
181 |
- if conf['type'] == 'plot': |
182 |
- plotf = plt.plot |
183 |
- elif conf['type'] == 'semilogx': |
184 |
- plotf = plt.semilogx |
185 |
- elif conf['type'] == 'semilogy': |
186 |
- plotf = plt.semilogy |
187 |
- elif conf['type'] == 'loglog': |
188 |
- plotf = plt.loglog |
189 |
- |
190 |
- if conf.has_key('xlabel'): |
191 |
- xlabel = conf['xlabel'] |
192 |
- else: |
193 |
- xlabel = '' |
194 |
- |
195 |
- if conf.has_key('ylabel'): |
196 |
- ylabel = conf['ylabel'] |
197 |
- else: |
198 |
- ylabel = '' |
199 |
- |
200 |
+ # Regenerate report in any case |
201 |
+ rmtree(cfg.reportdir, ignore_errors=True) |
202 |
|
203 |
# Open HTML file |
204 |
bu.mkdir(cfg.reportdir) |
205 |
+ bu.mkdir(pjoin(cfg.reportdir, 'images')) |
206 |
htmlfname = pjoin(cfg.reportdir, 'index.html') |
207 |
html = HTMLreport(htmlfname) |
208 |
|
209 |
for operation in cfg.mod.getTests(): |
210 |
- plt.figure(figsize=(12,9), dpi=300) |
211 |
- |
212 |
+ |
213 |
+ # Begin plot |
214 |
+ p = Plotter(cfg.mod.reportConf()) |
215 |
+ |
216 |
for tid,test in cfg.tests.items(): |
217 |
if test.has_key('implementations'): |
218 |
for impl in test['implementations']: |
219 |
if test['results'][impl].has_key(operation): |
220 |
resultsFile = test['results'][impl][operation] |
221 |
x,y = np.loadtxt(resultsFile, unpack=True) |
222 |
- plotf(x, y, label=tid+'/'+impl, hold=True) |
223 |
+ p.addPlot(x, y, tid+'/'+impl) |
224 |
|
225 |
- plt.legend(loc='best') |
226 |
- plt.xlabel(xlabel) |
227 |
- plt.ylabel(ylabel) |
228 |
- plt.grid(True) |
229 |
- |
230 |
- fname = pjoin(cfg.reportdir, operation+'.png') |
231 |
- plt.savefig(fname, format='png', bbox_inches='tight', transparent=True) |
232 |
- html.addFig(testdescr[operation], image=basename(fname)) |
233 |
+ imgpath = pjoin('images', operation+'.png') |
234 |
+ fname = pjoin(cfg.reportdir, imgpath) |
235 |
+ p.savePlot(fname) |
236 |
+ html.addFig(testdescr[operation], image=imgpath) |
237 |
|
238 |
# Close HTML file |
239 |
html.close() |