diff options
author | 2012-09-27 18:47:58 +0200 | |
---|---|---|
committer | 2012-09-27 18:47:58 +0200 | |
commit | 93b0b0031a1cb6629833055671236a54fa7b8c7a (patch) | |
tree | d9cb2d2f362ca2dee43803604a9ccdb3df221bbe | |
parent | Added initial support for copying the reports at the end (working for (diff) | |
download | auto-numerical-bench-93b0b0031a1cb6629833055671236a54fa7b8c7a.tar.gz auto-numerical-bench-93b0b0031a1cb6629833055671236a54fa7b8c7a.tar.bz2 auto-numerical-bench-93b0b0031a1cb6629833055671236a54fa7b8c7a.zip |
Add customizable title to the report. Solve the bug in module arguments.
-rw-r--r-- | numbench/benchconfig.py | 1 | ||||
-rw-r--r-- | numbench/main.py | 1 | ||||
-rw-r--r-- | numbench/modules/__init__.py | 6 | ||||
-rw-r--r-- | numbench/report.py | 2 | ||||
-rw-r--r-- | numbench/reports/html.py | 35 | ||||
-rw-r--r-- | numbench/xmlinput.py | 9 |
6 files changed, 33 insertions, 21 deletions
diff --git a/numbench/benchconfig.py b/numbench/benchconfig.py index ffdedba..fa8f4b8 100644 --- a/numbench/benchconfig.py +++ b/numbench/benchconfig.py @@ -44,6 +44,7 @@ copyreport = None module = None modulename = None moduleargs = None +reportTitle = None # Other isroot = not os.getuid() diff --git a/numbench/main.py b/numbench/main.py index cd0d3d7..c7c2a51 100644 --- a/numbench/main.py +++ b/numbench/main.py @@ -97,6 +97,7 @@ parser = Parser(cfg.inputfile) # Get module name and arguments cfg.modulename = parser.getModuleName() cfg.moduleargs = parser.getModuleArguments() +cfg.reportTitle = parser.getReportTitle() # Check whether the given module exists if not cfg.modulename in modules.getAllModulesNames(): diff --git a/numbench/modules/__init__.py b/numbench/modules/__init__.py index 9696252..be23a31 100644 --- a/numbench/modules/__init__.py +++ b/numbench/modules/__init__.py @@ -49,9 +49,9 @@ def loadModule(modname, args=None): if not modname in getModulesNames(): raise ModuleNotFoundException("module " + modname + " not found") - # Get the arguments string - args = "" if args is None else args - args = args if type(args) == type('') else ' '.join(args) + # Get the arguments tuple + args = () if args is None else args + args = tuple(args.split(' ')) if type(args) == type('') else tuple(args) # Load the module tmp = __import__('numbench.modules.' + modname, fromlist=["Module"]) diff --git a/numbench/report.py b/numbench/report.py index 6a0f584..6eb5d8c 100644 --- a/numbench/report.py +++ b/numbench/report.py @@ -83,7 +83,7 @@ def saveReport(): bu.mkdir(cfg.reportdir) bu.mkdir(pjoin(cfg.reportdir, 'images')) htmlfname = pjoin(cfg.reportdir, 'index.html') - html = HTMLreport(htmlfname) + html = HTMLreport(htmlfname, cfg.reportTitle) for operation in cfg.module.getTests(): diff --git a/numbench/reports/html.py b/numbench/reports/html.py index 5a45c35..26b5a96 100644 --- a/numbench/reports/html.py +++ b/numbench/reports/html.py @@ -30,7 +30,7 @@ class ReportFile: self.content = """ <html> <head> -<title>Benchmarks report</title> +<title>""" + title + """</title> <style type="text/css"> body { background-color: #FFFFFF; @@ -60,30 +60,33 @@ h1, h2, .plot, .descr, .info { </style> </head> <body> -<h1> -""" - self.content += title + '</h1>' +<h1>""" + title + "</h1>" date = time.strftime('%Y-%m-%d, %I:%M %p') self.content += '<p class="info">Generated on ' + date + '</p>' # Information regarding the CPU cpuinfo = file('/proc/cpuinfo', 'r').readlines() cpu = None + corecount = 0 for l in cpuinfo: - if l[:10] == 'model name': - cpu = l.split(':',1)[1].strip() + if l.startswith('model name'): + cpu = l.split(':', 1)[1].strip() + if l.startswith('processor'): + corecount += 1 + if cpu: - self.content += '<p class="info">CPU: ' + cpu + '</p>' - + self.content += '<p class="info">CPU: ' + cpu + \ + ' (' + str(corecount) + ' cores)</p>' + # Information regarding the memory meminfo = file('/proc/meminfo', 'r').readlines() mem = None for l in meminfo: if l[:8] == 'MemTotal': - mem = l.split(':',1)[1].strip() + mem = l.split(':', 1)[1].strip() if mem: self.content += '<p class="info">Total memory: ' + mem + '</p>' - + # Information regarding the caches cachedir = '/sys/devices/system/cpu/cpu0/cache' if exists(cachedir): @@ -95,31 +98,31 @@ h1, h2, .plot, .descr, .info { ctxt += ': ' + file(pjoin(cdir, 'size')).read().strip()[:-1] self.content += ctxt + ' kB<br />' self.content += '</p>' - + # Input file self.content += '<div class="inputfile">Input file: ' + \ '<a href="%s">%s</a>' % (basename(inputfile), cfg.inputfile) + \ '<pre>%s</pre></div>' % xmlescape(file(cfg.inputfile, 'r').read()) - + self.content += '<div class="log">Logs: <a href="log">%s</a></div>' \ % cfg.logdir - - + + def addFig(self, title, image, descr='', alt='', width=None): self.content += '<div class="fig">' self.content += '<h2>' + title + '</h2>' if descr.strip() != '': self.content += '<p class="descr">' + descr + '</p>' self.content += '<div class="plot">' - self.content += '<a href="' + image + '">' + self.content += '<a href="' + image + '">' self.content += '<img src="' + image + '" alt="' + alt + '"' if width is not None: self.content += ' style="width:' + str(width) + '; height:auto"' self.content += ' /></a>' self.content += '</div>' self.content += '</div><hr />' - + def close(self): self.content += '</body></html>' f = file(self.fname, 'w') diff --git a/numbench/xmlinput.py b/numbench/xmlinput.py index 87d9824..0f495d4 100644 --- a/numbench/xmlinput.py +++ b/numbench/xmlinput.py @@ -16,11 +16,18 @@ class Parser: def getModuleArguments(self): opTag = self._dom.getElementsByTagName('operations')[0] try: - args = shlex.split(opTag.firstChild.data) + args = tuple(shlex.split(opTag.firstChild.data)) except AttributeError: args = () return args + def getReportTitle(self): + titleTag = self._dom.getElementsByTagName('title') + if len(titleTag) != 1: + return "Benchmarks report" + else: + return titleTag[0].firstChild.data + def getTestCases(self): testNodes = self._dom.getElementsByTagName('case') |