1 |
commit: 93b0b0031a1cb6629833055671236a54fa7b8c7a |
2 |
Author: Andrea Arteaga <andyspiros <AT> gmail <DOT> com> |
3 |
AuthorDate: Thu Sep 27 16:47:58 2012 +0000 |
4 |
Commit: Andrea Arteaga <andyspiros <AT> gmail <DOT> com> |
5 |
CommitDate: Thu Sep 27 16:47:58 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=93b0b003 |
7 |
|
8 |
Add customizable title to the report. Solve the bug in module arguments. |
9 |
|
10 |
--- |
11 |
numbench/benchconfig.py | 1 + |
12 |
numbench/main.py | 1 + |
13 |
numbench/modules/__init__.py | 6 +++--- |
14 |
numbench/report.py | 2 +- |
15 |
numbench/reports/html.py | 35 +++++++++++++++++++---------------- |
16 |
numbench/xmlinput.py | 9 ++++++++- |
17 |
6 files changed, 33 insertions(+), 21 deletions(-) |
18 |
|
19 |
diff --git a/numbench/benchconfig.py b/numbench/benchconfig.py |
20 |
index ffdedba..fa8f4b8 100644 |
21 |
--- a/numbench/benchconfig.py |
22 |
+++ b/numbench/benchconfig.py |
23 |
@@ -44,6 +44,7 @@ copyreport = None |
24 |
module = None |
25 |
modulename = None |
26 |
moduleargs = None |
27 |
+reportTitle = None |
28 |
|
29 |
# Other |
30 |
isroot = not os.getuid() |
31 |
|
32 |
diff --git a/numbench/main.py b/numbench/main.py |
33 |
index cd0d3d7..c7c2a51 100644 |
34 |
--- a/numbench/main.py |
35 |
+++ b/numbench/main.py |
36 |
@@ -97,6 +97,7 @@ parser = Parser(cfg.inputfile) |
37 |
# Get module name and arguments |
38 |
cfg.modulename = parser.getModuleName() |
39 |
cfg.moduleargs = parser.getModuleArguments() |
40 |
+cfg.reportTitle = parser.getReportTitle() |
41 |
|
42 |
# Check whether the given module exists |
43 |
if not cfg.modulename in modules.getAllModulesNames(): |
44 |
|
45 |
diff --git a/numbench/modules/__init__.py b/numbench/modules/__init__.py |
46 |
index 9696252..be23a31 100644 |
47 |
--- a/numbench/modules/__init__.py |
48 |
+++ b/numbench/modules/__init__.py |
49 |
@@ -49,9 +49,9 @@ def loadModule(modname, args=None): |
50 |
if not modname in getModulesNames(): |
51 |
raise ModuleNotFoundException("module " + modname + " not found") |
52 |
|
53 |
- # Get the arguments string |
54 |
- args = "" if args is None else args |
55 |
- args = args if type(args) == type('') else ' '.join(args) |
56 |
+ # Get the arguments tuple |
57 |
+ args = () if args is None else args |
58 |
+ args = tuple(args.split(' ')) if type(args) == type('') else tuple(args) |
59 |
|
60 |
# Load the module |
61 |
tmp = __import__('numbench.modules.' + modname, fromlist=["Module"]) |
62 |
|
63 |
diff --git a/numbench/report.py b/numbench/report.py |
64 |
index 6a0f584..6eb5d8c 100644 |
65 |
--- a/numbench/report.py |
66 |
+++ b/numbench/report.py |
67 |
@@ -83,7 +83,7 @@ def saveReport(): |
68 |
bu.mkdir(cfg.reportdir) |
69 |
bu.mkdir(pjoin(cfg.reportdir, 'images')) |
70 |
htmlfname = pjoin(cfg.reportdir, 'index.html') |
71 |
- html = HTMLreport(htmlfname) |
72 |
+ html = HTMLreport(htmlfname, cfg.reportTitle) |
73 |
|
74 |
for operation in cfg.module.getTests(): |
75 |
|
76 |
|
77 |
diff --git a/numbench/reports/html.py b/numbench/reports/html.py |
78 |
index 5a45c35..26b5a96 100644 |
79 |
--- a/numbench/reports/html.py |
80 |
+++ b/numbench/reports/html.py |
81 |
@@ -30,7 +30,7 @@ class ReportFile: |
82 |
self.content = """ |
83 |
<html> |
84 |
<head> |
85 |
-<title>Benchmarks report</title> |
86 |
+<title>""" + title + """</title> |
87 |
<style type="text/css"> |
88 |
body { |
89 |
background-color: #FFFFFF; |
90 |
@@ -60,30 +60,33 @@ h1, h2, .plot, .descr, .info { |
91 |
</style> |
92 |
</head> |
93 |
<body> |
94 |
-<h1> |
95 |
-""" |
96 |
- self.content += title + '</h1>' |
97 |
+<h1>""" + title + "</h1>" |
98 |
date = time.strftime('%Y-%m-%d, %I:%M %p') |
99 |
self.content += '<p class="info">Generated on ' + date + '</p>' |
100 |
|
101 |
# Information regarding the CPU |
102 |
cpuinfo = file('/proc/cpuinfo', 'r').readlines() |
103 |
cpu = None |
104 |
+ corecount = 0 |
105 |
for l in cpuinfo: |
106 |
- if l[:10] == 'model name': |
107 |
- cpu = l.split(':',1)[1].strip() |
108 |
+ if l.startswith('model name'): |
109 |
+ cpu = l.split(':', 1)[1].strip() |
110 |
+ if l.startswith('processor'): |
111 |
+ corecount += 1 |
112 |
+ |
113 |
if cpu: |
114 |
- self.content += '<p class="info">CPU: ' + cpu + '</p>' |
115 |
- |
116 |
+ self.content += '<p class="info">CPU: ' + cpu + \ |
117 |
+ ' (' + str(corecount) + ' cores)</p>' |
118 |
+ |
119 |
# Information regarding the memory |
120 |
meminfo = file('/proc/meminfo', 'r').readlines() |
121 |
mem = None |
122 |
for l in meminfo: |
123 |
if l[:8] == 'MemTotal': |
124 |
- mem = l.split(':',1)[1].strip() |
125 |
+ mem = l.split(':', 1)[1].strip() |
126 |
if mem: |
127 |
self.content += '<p class="info">Total memory: ' + mem + '</p>' |
128 |
- |
129 |
+ |
130 |
# Information regarding the caches |
131 |
cachedir = '/sys/devices/system/cpu/cpu0/cache' |
132 |
if exists(cachedir): |
133 |
@@ -95,31 +98,31 @@ h1, h2, .plot, .descr, .info { |
134 |
ctxt += ': ' + file(pjoin(cdir, 'size')).read().strip()[:-1] |
135 |
self.content += ctxt + ' kB<br />' |
136 |
self.content += '</p>' |
137 |
- |
138 |
+ |
139 |
|
140 |
# Input file |
141 |
self.content += '<div class="inputfile">Input file: ' + \ |
142 |
'<a href="%s">%s</a>' % (basename(inputfile), cfg.inputfile) + \ |
143 |
'<pre>%s</pre></div>' % xmlescape(file(cfg.inputfile, 'r').read()) |
144 |
- |
145 |
+ |
146 |
self.content += '<div class="log">Logs: <a href="log">%s</a></div>' \ |
147 |
% cfg.logdir |
148 |
- |
149 |
- |
150 |
+ |
151 |
+ |
152 |
def addFig(self, title, image, descr='', alt='', width=None): |
153 |
self.content += '<div class="fig">' |
154 |
self.content += '<h2>' + title + '</h2>' |
155 |
if descr.strip() != '': |
156 |
self.content += '<p class="descr">' + descr + '</p>' |
157 |
self.content += '<div class="plot">' |
158 |
- self.content += '<a href="' + image + '">' |
159 |
+ self.content += '<a href="' + image + '">' |
160 |
self.content += '<img src="' + image + '" alt="' + alt + '"' |
161 |
if width is not None: |
162 |
self.content += ' style="width:' + str(width) + '; height:auto"' |
163 |
self.content += ' /></a>' |
164 |
self.content += '</div>' |
165 |
self.content += '</div><hr />' |
166 |
- |
167 |
+ |
168 |
def close(self): |
169 |
self.content += '</body></html>' |
170 |
f = file(self.fname, 'w') |
171 |
|
172 |
diff --git a/numbench/xmlinput.py b/numbench/xmlinput.py |
173 |
index 87d9824..0f495d4 100644 |
174 |
--- a/numbench/xmlinput.py |
175 |
+++ b/numbench/xmlinput.py |
176 |
@@ -16,11 +16,18 @@ class Parser: |
177 |
def getModuleArguments(self): |
178 |
opTag = self._dom.getElementsByTagName('operations')[0] |
179 |
try: |
180 |
- args = shlex.split(opTag.firstChild.data) |
181 |
+ args = tuple(shlex.split(opTag.firstChild.data)) |
182 |
except AttributeError: |
183 |
args = () |
184 |
return args |
185 |
|
186 |
+ def getReportTitle(self): |
187 |
+ titleTag = self._dom.getElementsByTagName('title') |
188 |
+ if len(titleTag) != 1: |
189 |
+ return "Benchmarks report" |
190 |
+ else: |
191 |
+ return titleTag[0].firstChild.data |
192 |
+ |
193 |
def getTestCases(self): |
194 |
testNodes = self._dom.getElementsByTagName('case') |