summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Arteaga <andyspiros@gmail.com>2012-02-24 18:58:34 +0100
committerAndrea Arteaga <andyspiros@gmail.com>2012-02-24 18:58:34 +0100
commitb92f48b60548d0be057bc9dbe264e00fc186227f (patch)
tree8769044701a15c9223a3b11197fee3b2dbc55d89
parentAdded wildcards and regexp support for skip. Fixed a few bugs. (diff)
downloadauto-numerical-bench-b92f48b60548d0be057bc9dbe264e00fc186227f.tar.gz
auto-numerical-bench-b92f48b60548d0be057bc9dbe264e00fc186227f.tar.bz2
auto-numerical-bench-b92f48b60548d0be057bc9dbe264e00fc186227f.zip
New Plotter class
-rw-r--r--blastests.xml3
-rw-r--r--numbench/confinput/xmlinput.py2
-rw-r--r--numbench/htmlreport.py2
-rw-r--r--numbench/modules/internal/blasBase.py6
-rw-r--r--numbench/modules/internal/btlBase.py2
-rw-r--r--numbench/report.py95
6 files changed, 68 insertions, 42 deletions
diff --git a/blastests.xml b/blastests.xml
index 75f5ba4..d01615b 100644
--- a/blastests.xml
+++ b/blastests.xml
@@ -1,10 +1,13 @@
<tests>
+
+<!--
<test id="reference">
<pkg>sci-libs/blas-reference-20120215-r1</pkg>
<emergeenv>
<var name="FFLAGS">-O3</var>
</emergeenv>
</test>
+-->
<!--
<test id="atlas">
diff --git a/numbench/confinput/xmlinput.py b/numbench/confinput/xmlinput.py
index 2a145a9..4743730 100644
--- a/numbench/confinput/xmlinput.py
+++ b/numbench/confinput/xmlinput.py
@@ -105,7 +105,7 @@ def parseConf(fname):
skip = []
skipre = []
for s in t.getElementsByTagName('skip'):
- if not s.hasAtribute('type') or s.getAttribute('type') == 'glob':
+ if not s.hasAttribute('type') or s.getAttribute('type') == 'glob':
skip.append(s.firstChild.data)
elif s.getAttribute('type') == 'regexp':
skipre.append(s.firstChild.data)
diff --git a/numbench/htmlreport.py b/numbench/htmlreport.py
index 33c19fa..0439aff 100644
--- a/numbench/htmlreport.py
+++ b/numbench/htmlreport.py
@@ -91,7 +91,7 @@ h1, h2, .plot, .descr, .info {
def addFig(self, title, image, descr='', alt='', width=None):
self.content += '<div class="fig">'
self.content += '<h2>' + title + '</h2>'
- if descr.strip() != '':
+ if descr.strip() != '':
self.content += '<p class="descr">' + descr + '</p>'
self.content += '<div class="plot">'
self.content += '<a href="' + image + '">'
diff --git a/numbench/modules/internal/blasBase.py b/numbench/modules/internal/blasBase.py
index 5e691e3..cf8ba07 100644
--- a/numbench/modules/internal/blasBase.py
+++ b/numbench/modules/internal/blasBase.py
@@ -32,10 +32,6 @@ def init(self, args):
passargs = []
tests = []
- if len(args) == 0:
- self.tests = defaultTests
- return
-
for i in args:
if i == '1':
tests += avail1
@@ -49,6 +45,8 @@ def init(self, args):
passargs.append(i)
self.tests = btl.selectTests(availableTests, passargs+tests)
+ if len(self.tests) == 0:
+ self.tests = defaultTests
def getImplementations(self, test):
diff --git a/numbench/modules/internal/btlBase.py b/numbench/modules/internal/btlBase.py
index 3c33202..8237692 100644
--- a/numbench/modules/internal/btlBase.py
+++ b/numbench/modules/internal/btlBase.py
@@ -26,7 +26,7 @@ def reportConf(*args):
def runTest(self, test, btlconfig):
# Check if results already exist
tmpres = dict( \
- [(i, pjoin(btlconfig['testdir'], "bench_"+i+"_"+self.libname)) \
+ [(i, pjoin(btlconfig['testdir'], 'bench_'+i+'_'+self.libname+'.dat')) \
for i in btlconfig['tests']])
if all([exists(i) for i in tmpres.values()]):
diff --git a/numbench/report.py b/numbench/report.py
index 901723b..75be5c4 100644
--- a/numbench/report.py
+++ b/numbench/report.py
@@ -16,7 +16,8 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
from os.path import join as pjoin, basename
-import numpy as np
+import sys, numpy as np
+from shutil import rmtree
import benchconfig as cfg
import benchutils as bu
@@ -24,8 +25,53 @@ from htmlreport import HTMLreport
from testdescr import testdescr
from benchprint import Print
-def saveReport():
+class Plotter:
+ def __init__(self, conf):
+ # Set plot function
+ self.conf = conf
+ if not conf.has_key('type'):
+ self.plotf = plt.plot
+ elif type(conf['type']) == type(''):
+ try:
+ self.plotf = plt.__dict__[conf['type']]
+ except:
+ print >> sys.stderr, \
+ 'Plot function "', conf['type'], '" not found. Using plot'
+ self.plotf = plt.plot
+ return
+ else:
+ self.plot = conf['type']
+
+ # Labels
+ self.xlabel = conf.has_key('xlabel') and conf['xlabel'] or ''
+ self.ylabel = conf.has_key('ylabel') and conf['ylabel'] or ''
+
+ # Initialize markers
+ markers = ('-', '--', 'o', 'v', '^', 's', 'p', 'h', '*', '+', 'x', 'D')
+ colors = ('k', 'r', 'g', 'b')
+ self.linestyles = tuple([c+m for m in markers for c in colors])
+ self.curstyle = 0
+
+ # Open figure
+ plt.figure(figsize=(12,9), dpi=300)
+
+
+ def addPlot(self, x, y, label):
+ style = self.linestyles[self.curstyle]
+ self.curstyle = (self.curstyle+1) % len(self.linestyles)
+ self.plotf(x, y, style, label=label, hold=True)
+
+ def savePlot(self, fname):
+ plt.legend(loc='best')
+ plt.xlabel(self.xlabel)
+ plt.ylabel(self.ylabel)
+ plt.grid(True)
+ plt.savefig(fname, format='png', bbox_inches='tight', transparent=True)
+
+
+
+def saveReport():
# Check whether pyplot is working
try:
plt.figure()
@@ -34,53 +80,32 @@ def saveReport():
Print("Please make sure that X is running and $DISPLAY is set")
return
- # Read configuration
- conf = cfg.mod.reportConf()
-
- if conf['type'] == 'plot':
- plotf = plt.plot
- elif conf['type'] == 'semilogx':
- plotf = plt.semilogx
- elif conf['type'] == 'semilogy':
- plotf = plt.semilogy
- elif conf['type'] == 'loglog':
- plotf = plt.loglog
-
- if conf.has_key('xlabel'):
- xlabel = conf['xlabel']
- else:
- xlabel = ''
-
- if conf.has_key('ylabel'):
- ylabel = conf['ylabel']
- else:
- ylabel = ''
-
+ # Regenerate report in any case
+ rmtree(cfg.reportdir, ignore_errors=True)
# Open HTML file
bu.mkdir(cfg.reportdir)
+ bu.mkdir(pjoin(cfg.reportdir, 'images'))
htmlfname = pjoin(cfg.reportdir, 'index.html')
html = HTMLreport(htmlfname)
for operation in cfg.mod.getTests():
- plt.figure(figsize=(12,9), dpi=300)
-
+
+ # Begin plot
+ p = Plotter(cfg.mod.reportConf())
+
for tid,test in cfg.tests.items():
if test.has_key('implementations'):
for impl in test['implementations']:
if test['results'][impl].has_key(operation):
resultsFile = test['results'][impl][operation]
x,y = np.loadtxt(resultsFile, unpack=True)
- plotf(x, y, label=tid+'/'+impl, hold=True)
+ p.addPlot(x, y, tid+'/'+impl)
- plt.legend(loc='best')
- plt.xlabel(xlabel)
- plt.ylabel(ylabel)
- plt.grid(True)
-
- fname = pjoin(cfg.reportdir, operation+'.png')
- plt.savefig(fname, format='png', bbox_inches='tight', transparent=True)
- html.addFig(testdescr[operation], image=basename(fname))
+ imgpath = pjoin('images', operation+'.png')
+ fname = pjoin(cfg.reportdir, imgpath)
+ p.savePlot(fname)
+ html.addFig(testdescr[operation], image=imgpath)
# Close HTML file
html.close()