blob: f9c91a450300b60f0a9d9f0eb277ce9d5c9e32ec [file] [log] [blame]
Christophe Favergeon8cb37302020-05-13 13:06:58 +02001import argparse
2import sqlite3
3import re
4import pandas as pd
5import numpy as np
6
Christophe Favergeon34d313a2020-05-14 15:09:41 +02007remapNames={
8 "BasicMathsBenchmarks": "Basic Maths",
9 "ComplexMathsBenchmarks": "Complex Maths",
10 "FIR": "FIR",
11 "MISC": "Convolutions / Correlations",
12 "DECIM": "Decimations / Interpolations",
13 "BIQUAD": "BiQuad",
14 "FastMath": "Fast Maths",
15 "SupportBar": "Barycenter",
16 "Support": "Support Functions",
17 "Unary": "Matrix Unary Operations",
18 "Binary": "Matrix Binary Operations",
19 "Transform": "Vector Transform"
20}
21
22def convertSectionName(s):
23 if s in remapNames:
24 return(remapNames[s])
25 else:
26 return(s)
27
Christophe Favergeonc3f455c2020-05-14 09:24:07 +020028class Document:
29 def __init__(self,runid,date):
30 self._runid = runid
31 self._date = date
32 self._sections = []
33
34 @property
35 def runid(self):
36 return(self._runid)
37
38 @property
39 def date(self):
40 return(self._date)
41
42 @property
43 def sections(self):
44 return(self._sections)
45
46 def addSection(self,section):
47 self._sections.append(section)
48
49 def accept(self, visitor):
50 visitor.visitDocument(self)
51 for element in self._sections:
52 element.accept(visitor)
53 visitor.leaveDocument(self)
54
55class Section:
56 def __init__(self,name):
Christophe Favergeon34d313a2020-05-14 15:09:41 +020057 self._name=convertSectionName(name)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +020058 self._subsections = []
59 self._tables = []
60
61 def addSection(self,section):
62 self._subsections.append(section)
63
64 def addTable(self,table):
65 self._tables.append(table)
66
67 @property
68 def hasChildren(self):
69 return(len(self._subsections)>0)
70
71 @property
72 def name(self):
73 return(self._name)
74
75 def accept(self, visitor):
76 visitor.visitSection(self)
77 for element in self._subsections:
78 element.accept(visitor)
79 for element in self._tables:
80 element.accept(visitor)
81 visitor.leaveSection(self)
82
83class Table:
Christophe Favergeon34d313a2020-05-14 15:09:41 +020084 def __init__(self,params,cores):
85 self._params=params
86 self._cores=cores
Christophe Favergeonc3f455c2020-05-14 09:24:07 +020087 self._rows=[]
88
89 def addRow(self,row):
90 self._rows.append(row)
91
92 @property
93 def columns(self):
Christophe Favergeon34d313a2020-05-14 15:09:41 +020094 return(self._params + self._cores)
95
96 @property
97 def params(self):
98 return(self._params)
99
100 @property
101 def cores(self):
102 return(self._cores)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200103
104 @property
105 def rows(self):
106 return(self._rows)
107
108 def accept(self, visitor):
109 visitor.visitTable(self)
110
111
112
113class Markdown:
114 def __init__(self,output):
115 self._id=0
116 self._output = output
117
118 # Write columns in markdown format
119 def writeColumns(self,cols):
120 colStr = "".join(joinit(cols,"|"))
121 self._output.write("|")
122 self._output.write(colStr)
123 self._output.write("|\n")
124 sepStr="".join(joinit([":-:" for x in cols],"|"))
125 self._output.write("|")
126 self._output.write(sepStr)
127 self._output.write("|\n")
128
129 # Write row in markdown format
130 def writeRow(self,row):
131 row=[str(x) for x in row]
132 rowStr = "".join(joinit(row,"|"))
133 self._output.write("|")
134 self._output.write(rowStr)
135 self._output.write("|\n")
136
137 def visitTable(self,table):
138 self.writeColumns(table.columns)
139 for row in table.rows:
140 self.writeRow(row)
141
142 def visitSection(self,section):
143 self._id = self._id + 1
144 header = "".join(["#" for i in range(self._id)])
145 output.write("%s %s\n" % (header,section.name))
146
147 def leaveSection(self,section):
148 self._id = self._id - 1
149
150 def visitDocument(self,document):
151 self._output.write("Run number %d on %s\n" % (document.runid, str(document.date)))
152
153 def leaveDocument(self,document):
154 pass
155
156styleSheet="""
157<style type='text/css'>
158
159#TOC {
160 position: fixed;
161 left: 0;
162 top: 0;
163 width: 250px;
164 height: 100%;
165 overflow:auto;
Christophe Favergeon34d313a2020-05-14 15:09:41 +0200166 margin-top:5px;
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200167}
168
169html {
170 font-size: 16px;
171}
172
173html, body {
174 background-color: #f3f2ee;
175 font-family: "PT Serif", 'Times New Roman', Times, serif;
176 color: #1f0909;
177 line-height: 1.5em;
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200178}
179
Christophe Favergeon34d313a2020-05-14 15:09:41 +0200180body {
181 margin: auto;
182 margin-top:0px;
183 margin-left:250px;
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200184
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200185}
186
187h1,
188h2,
189h3,
190h4,
191h5,
192h6 {
193 font-weight: bold;
194}
195h1 {
196 font-size: 1.875em;
Christophe Favergeon34d313a2020-05-14 15:09:41 +0200197 margin-top:5px;
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200198}
Christophe Favergeon34d313a2020-05-14 15:09:41 +0200199h2 {
200 font-size: 1.3125em;
201}
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200202h3 {
203 font-size: 1.3125em;
Christophe Favergeon34d313a2020-05-14 15:09:41 +0200204 margin-left:1em;
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200205}
206h4 {
207 font-size: 1.125em;
Christophe Favergeon34d313a2020-05-14 15:09:41 +0200208 margin-left:1em;
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200209}
210h5,
211h6 {
212 font-size: 1em;
213}
214
Christophe Favergeon34d313a2020-05-14 15:09:41 +0200215#TOC h1 {
216 margin-top:0em;
217 margin-left:0.5em;
218}
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200219
220table {
221 margin-bottom: 1.5em;
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200222 font-size: 1em;
Christophe Favergeon34d313a2020-05-14 15:09:41 +0200223 width: 100%;
224 border-collapse: collapse;
225 border-spacing: 0;
226 width: 100%;
227 margin-left:1em;
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200228}
229thead th,
230tfoot th {
231 padding: .25em .25em .25em .4em;
232 text-transform: uppercase;
233}
234th {
235 text-align: left;
236}
237td {
238 vertical-align: top;
239 padding: .25em .25em .25em .4em;
240}
241
242.ty-table-edit {
243 background-color: transparent;
244}
245thead {
246 background-color: #dadada;
247}
248tr:nth-child(even) {
249 background: #e8e7e7;
250}
251
252ul, #myUL {
253 list-style-type: none;
254 padding-inline-start:10px;
255}
256
257
258
259/* Remove margins and padding from the parent ul */
260#myUL {
261 margin: 0;
262 padding: 0;
263}
264
265/* Style the caret/arrow */
266.caret {
267 cursor: pointer;
268 user-select: none; /* Prevent text selection */
269}
270
271/* Create the caret/arrow with a unicode, and style it */
272.caret::before {
273 content: "\\25B6";
274 color: black;
275 display: inline-block;
276 margin-right: 6px;
277}
278
279/* Rotate the caret/arrow icon when clicked on (using JavaScript) */
280.caret-down::before {
281 transform: rotate(90deg);
282}
283
284/* Hide the nested list */
285.nested {
286 display: none;
287}
288
289/* Show the nested list when the user clicks on the caret/arrow (with JavaScript) */
290.active {
291 display: block;
292}
293
294</style>
295"""
296
297script="""<script type="text/javascript">
298var toggler = document.getElementsByClassName("caret");
299var i;
300for (i = 0; i < toggler.length; i++) {
301 toggler[i].addEventListener("click", function() {
302 this.parentElement.querySelector(".nested").classList.toggle("active");
303 this.classList.toggle("caret-down");
304 });
305}</script>"""
306
307
308class HTMLToc:
309 def __init__(self,output):
310 self._id=0
311 self._sectionID = 0
312 self._output = output
313
314
315
316 def visitTable(self,table):
317 pass
318
319
320 def visitSection(self,section):
321 self._id = self._id + 1
322 self._sectionID = self._sectionID + 1
323 if section.hasChildren:
324 self._output.write("<li><span class=\"caret\"><a href=\"#section%d\">%s</a></span>\n" % (self._sectionID,section.name))
325 self._output.write("<ul class=\"nested\">\n")
326 else:
327 self._output.write("<li><span><a href=\"#section%d\">%s</a></span>\n" % (self._sectionID,section.name))
328
329 def leaveSection(self,section):
330 if section.hasChildren:
331 self._output.write("</ul></li>\n")
332
333 self._id = self._id - 1
334
335 def visitDocument(self,document):
336 self._output.write("<div id=\"TOC\"><h1>Table of content</h1><ul id=\"myUL\">\n")
337
338
339 def leaveDocument(self,document):
340 self._output.write("</ul></div>%s\n" % script)
341
342
343class HTML:
344 def __init__(self,output):
345 self._id=0
346 self._sectionID = 0
347 self._output = output
348
349
350
351 def visitTable(self,table):
352 output.write("<table>\n")
353 output.write("<thead>\n")
354 output.write("<tr>\n")
355 for col in table.columns:
356 output.write("<th>")
357 output.write(str(col))
358 output.write("</th>\n")
359 output.write("</tr>\n")
360 output.write("</thead>\n")
361 for row in table.rows:
362 output.write("<tr>\n")
363 for elem in row:
364 output.write("<td>")
365 output.write(str(elem))
366 output.write("</td>\n")
367 output.write("</tr>\n")
368 output.write("</table>\n")
369
370
371 def visitSection(self,section):
372 self._id = self._id + 1
373 self._sectionID = self._sectionID + 1
374 output.write("<h%d id=\"section%d\">%s</h%d>\n" % (self._id,self._sectionID,section.name,self._id))
375
376 def leaveSection(self,section):
377 self._id = self._id - 1
378
379 def visitDocument(self,document):
380 self._output.write("""<!doctype html>
381<html>
382<head>
383<meta charset='UTF-8'><meta name='viewport' content='width=device-width initial-scale=1'>
384<title>Benchmarks</title>%s</head><body>\n""" % styleSheet)
Christophe Favergeon34d313a2020-05-14 15:09:41 +0200385 self._output.write("<h1>ECPS Benchmark Summary</h1>\n")
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200386 self._output.write("<p>Run number %d on %s</p>\n" % (document.runid, str(document.date)))
387
388 def leaveDocument(self,document):
389 document.accept(HTMLToc(self._output))
390
391 self._output.write("</body></html>\n")
392
393
394
395
396
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200397# Command to get last runid
398lastID="""SELECT runid FROM RUN ORDER BY runid DESC LIMIT 1
399"""
400
Christophe Favergeone15894e2020-05-14 07:25:53 +0200401# Command to get last runid and date
402lastIDAndDate="""SELECT date FROM RUN WHERE runid=?
403"""
404
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200405def getLastRunID():
406 r=c.execute(lastID)
407 return(int(r.fetchone()[0]))
408
Christophe Favergeone15894e2020-05-14 07:25:53 +0200409def getrunIDDate(forID):
410 r=c.execute(lastIDAndDate,(forID,))
411 return(r.fetchone()[0])
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200412
413runid = 1
414
415parser = argparse.ArgumentParser(description='Generate summary benchmarks')
416
417parser.add_argument('-b', nargs='?',type = str, default="bench.db", help="Benchmark database")
418parser.add_argument('-o', nargs='?',type = str, default="full.md", help="Full summary")
419parser.add_argument('-r', action='store_true', help="Regression database")
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200420parser.add_argument('-t', nargs='?',type = str, default="md", help="md,html")
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200421
422# For runid or runid range
423parser.add_argument('others', nargs=argparse.REMAINDER)
424
425args = parser.parse_args()
426
427c = sqlite3.connect(args.b)
428
429if args.others:
430 runid=int(args.others[0])
431else:
432 runid=getLastRunID()
433
434# We extract data only from data tables
435# Those tables below are used for descriptions
436REMOVETABLES=['RUN','CORE', 'PLATFORM', 'COMPILERKIND', 'COMPILER', 'TYPE', 'CATEGORY', 'CONFIG']
437
438# This is assuming the database is generated by the regression script
439# So platform is the same for all benchmarks.
440# Category and type is coming from the test name in the yaml
441# So no need to add this information here
442# Name is removed here because it is added at the beginning
443REMOVECOLUMNS=['runid','NAME','type','platform','category','coredef','OPTIMIZED','HARDFP','FASTMATH','NEON','HELIUM','UNROLL','ROUNDING','DATE','compilerkindid','date','categoryid', 'ID', 'platformid', 'coreid', 'compilerid', 'typeid']
444
445# Get existing benchmark tables
446def getBenchTables():
447 r=c.execute("SELECT name FROM sqlite_master WHERE type='table'")
448 benchtables=[]
449 for table in r:
450 if not table[0] in REMOVETABLES:
451 benchtables.append(table[0])
452 return(benchtables)
453
454# get existing types in a table
455def getExistingTypes(benchTable):
Christophe Favergeone15894e2020-05-14 07:25:53 +0200456 r=c.execute("select distinct typeid from %s order by typeid desc" % benchTable).fetchall()
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200457 result=[x[0] for x in r]
458 return(result)
459
460# Get compilers from specific type and table
461versioncompiler="""select distinct compiler,version from %s
462 INNER JOIN COMPILER USING(compilerid)
463 INNER JOIN COMPILERKIND USING(compilerkindid) WHERE typeid=?"""
464
465# Get existing compiler in a table for a specific type
466# (In case report is structured by types)
467def getExistingCompiler(benchTable,typeid):
468 r=c.execute(versioncompiler % benchTable,(typeid,)).fetchall()
469 return(r)
470
471# Get type name from type id
472def getTypeName(typeid):
473 r=c.execute("select type from TYPE where typeid=?",(typeid,)).fetchone()
474 return(r[0])
475
476# Diff of 2 lists
477def diff(first, second):
478 second = set(second)
479 return [item for item in first if item not in second]
480
481
482# Command to get data for specific compiler
483# and type
484benchCmd="""select %s from %s
485 INNER JOIN CATEGORY USING(categoryid)
486 INNER JOIN PLATFORM USING(platformid)
487 INNER JOIN CORE USING(coreid)
488 INNER JOIN COMPILER USING(compilerid)
489 INNER JOIN COMPILERKIND USING(compilerkindid)
490 INNER JOIN TYPE USING(typeid)
491 WHERE compiler=? AND VERSION=? AND typeid = ? AND runid = ?
492 """
493
Christophe Favergeon4f750702020-05-13 15:56:15 +0200494
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200495# Command to get test names for specific compiler
496# and type
497benchNames="""select distinct NAME from %s
498 INNER JOIN COMPILER USING(compilerid)
499 INNER JOIN COMPILERKIND USING(compilerkindid)
500 INNER JOIN TYPE USING(typeid)
501 WHERE compiler=? AND VERSION=? AND typeid = ? AND runid = ?
502 """
503
504# Command to get columns for specific table
505benchCmdColumns="""select * from %s
506 INNER JOIN CATEGORY USING(categoryid)
507 INNER JOIN PLATFORM USING(platformid)
508 INNER JOIN CORE USING(coreid)
509 INNER JOIN COMPILER USING(compilerid)
510 INNER JOIN COMPILERKIND USING(compilerkindid)
511 INNER JOIN TYPE USING(typeid)
512 """
513
514def joinit(iterable, delimiter):
515 it = iter(iterable)
516 yield next(it)
517 for x in it:
518 yield delimiter
519 yield x
520
521# Is not a column name finishing by id
522# (often primary key for thetable)
523def isNotIDColumn(col):
524 if re.match(r'^.*id$',col):
525 return(False)
526 else:
527 return(True)
528
529# Get test names
530# for specific typeid and compiler (for the data)
531def getTestNames(benchTable,comp,typeid):
532 vals=(comp[0],comp[1],typeid,runid)
533 result=c.execute(benchNames % benchTable,vals).fetchall()
534 return([x[0] for x in list(result)])
535
Christophe Favergeone15894e2020-05-14 07:25:53 +0200536# Command to get data for specific compiler
537# and type
538nbElemsInBenchAndTypeAndCompilerCmd="""select count(*) from %s
539 INNER JOIN CATEGORY USING(categoryid)
540 INNER JOIN PLATFORM USING(platformid)
541 INNER JOIN CORE USING(coreid)
542 INNER JOIN COMPILER USING(compilerid)
543 INNER JOIN COMPILERKIND USING(compilerkindid)
544 INNER JOIN TYPE USING(typeid)
545 WHERE compiler=? AND VERSION=? AND typeid = ? AND runid = ?
546 """
547
548nbElemsInBenchAndTypeCmd="""select count(*) from %s
549 INNER JOIN CATEGORY USING(categoryid)
550 INNER JOIN PLATFORM USING(platformid)
551 INNER JOIN CORE USING(coreid)
552 INNER JOIN COMPILER USING(compilerid)
553 INNER JOIN COMPILERKIND USING(compilerkindid)
554 INNER JOIN TYPE USING(typeid)
555 WHERE typeid = ? AND runid = ?
556 """
557
558nbElemsInBenchCmd="""select count(*) from %s
559 INNER JOIN CATEGORY USING(categoryid)
560 INNER JOIN PLATFORM USING(platformid)
561 INNER JOIN CORE USING(coreid)
562 INNER JOIN COMPILER USING(compilerid)
563 INNER JOIN COMPILERKIND USING(compilerkindid)
564 INNER JOIN TYPE USING(typeid)
565 WHERE runid = ?
566 """
567
Christophe Favergeon4f750702020-05-13 15:56:15 +0200568# Get nb elems in a table
Christophe Favergeone15894e2020-05-14 07:25:53 +0200569def getNbElemsInBenchAndTypeAndCompilerCmd(benchTable,comp,typeid):
Christophe Favergeon4f750702020-05-13 15:56:15 +0200570 vals=(comp[0],comp[1],typeid,runid)
Christophe Favergeone15894e2020-05-14 07:25:53 +0200571 result=c.execute(nbElemsInBenchAndTypeAndCompilerCmd % benchTable,vals).fetchone()
572 return(result[0])
573
574def getNbElemsInBenchAndTypeCmd(benchTable,typeid):
575 vals=(typeid,runid)
576 result=c.execute(nbElemsInBenchAndTypeCmd % benchTable,vals).fetchone()
577 return(result[0])
578
579def getNbElemsInBenchCmd(benchTable):
580 vals=(runid,)
581 result=c.execute(nbElemsInBenchCmd % benchTable,vals).fetchone()
Christophe Favergeon4f750702020-05-13 15:56:15 +0200582 return(result[0])
583
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200584# Get names of columns and data for a table
585# for specific typeid and compiler (for the data)
586def getColNamesAndData(benchTable,comp,typeid):
587 cursor=c.cursor()
588 result=cursor.execute(benchCmdColumns % (benchTable))
589 cols= [member[0] for member in cursor.description]
590 keepCols = ['NAME'] + [c for c in diff(cols , REMOVECOLUMNS) if isNotIDColumn(c)]
591 keepColsStr = "".join(joinit(keepCols,","))
592 vals=(comp[0],comp[1],typeid,runid)
593 result=cursor.execute(benchCmd % (keepColsStr,benchTable),vals)
594 vals =np.array([list(x) for x in list(result)])
595 return(keepCols,vals)
596
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200597
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200598
599PARAMS=["NB","NumTaps", "NBA", "NBB", "Factor", "NumStages","VECDIM","NBR","NBC","NBI","IFFT", "BITREV"]
600
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200601def regressionTableFor(name,section,ref,toSort,indexCols,field):
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200602 data=ref.pivot_table(index=indexCols, columns='core',
603 values=[field], aggfunc='first')
604
605 data=data.sort_values(toSort)
606
607 cores = [c[1] for c in list(data.columns)]
Christophe Favergeon34d313a2020-05-14 15:09:41 +0200608 columns = diff(indexCols,['NAME'])
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200609
Christophe Favergeon34d313a2020-05-14 15:09:41 +0200610 dataTable=Table(columns,cores)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200611 section.addTable(dataTable)
612
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200613 dataForFunc=data.loc[name]
614 if type(dataForFunc) is pd.DataFrame:
615 for row in dataForFunc.itertuples():
616 row=list(row)
617 if type(row[0]) is int:
618 row=[row[0]] + row[1:]
619 else:
620 row=list(row[0]) + row[1:]
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200621 dataTable.addRow(row)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200622 else:
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200623 dataTable.addRow(dataForFunc)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200624
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200625def formatTableByCore(typeSection,testNames,cols,vals):
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200626 if vals.size != 0:
627 ref=pd.DataFrame(vals,columns=cols)
628 toSort=["NAME"]
629
630 for param in PARAMS:
631 if param in ref.columns:
632 ref[param]=pd.to_numeric(ref[param])
633 toSort.append(param)
634 if args.r:
635 # Regression table
636 ref['MAX']=pd.to_numeric(ref['MAX'])
637 ref['MAXREGCOEF']=pd.to_numeric(ref['MAXREGCOEF'])
638
639 indexCols=diff(cols,['core','Regression','MAXREGCOEF','MAX','version','compiler'])
640 valList = ['Regression']
641 else:
642 ref['CYCLES']=pd.to_numeric(ref['CYCLES'])
643
644 indexCols=diff(cols,['core','CYCLES','version','compiler'])
645 valList = ['CYCLES']
646
647
648
649 for name in testNames:
650 if args.r:
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200651 testSection = Section(name)
652 typeSection.addSection(testSection)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200653
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200654 regressionSection = Section("Regression")
655 testSection.addSection(regressionSection)
656 regressionTableFor(name,regressionSection,ref,toSort,indexCols,'Regression')
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200657
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200658 maxCyclesSection = Section("Max cycles")
659 testSection.addSection(maxCyclesSection)
660 regressionTableFor(name,maxCyclesSection,ref,toSort,indexCols,'MAX')
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200661
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200662 maxRegCoefSection = Section("Max Reg Coef")
663 testSection.addSection(maxRegCoefSection)
664 regressionTableFor(name,maxRegCoefSection,ref,toSort,indexCols,'MAXREGCOEF')
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200665
666 else:
667 data=ref.pivot_table(index=indexCols, columns='core',
668 values=valList, aggfunc='first')
669
670 data=data.sort_values(toSort)
671
672 cores = [c[1] for c in list(data.columns)]
Christophe Favergeon34d313a2020-05-14 15:09:41 +0200673 columns = diff(indexCols,['NAME'])
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200674
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200675 testSection = Section(name)
676 typeSection.addSection(testSection)
677
Christophe Favergeon34d313a2020-05-14 15:09:41 +0200678 dataTable=Table(columns,cores)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200679 testSection.addTable(dataTable)
680
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200681 dataForFunc=data.loc[name]
682 if type(dataForFunc) is pd.DataFrame:
683 for row in dataForFunc.itertuples():
684 row=list(row)
685 if type(row[0]) is int:
686 row=[row[0]] + row[1:]
687 else:
688 row=list(row[0]) + row[1:]
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200689 dataTable.addRow(row)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200690 else:
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200691 dataTable.addRow(dataForFunc)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200692
693# Add a report for each table
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200694def addReportFor(document,benchName):
Christophe Favergeone15894e2020-05-14 07:25:53 +0200695 nbElems = getNbElemsInBenchCmd(benchName)
696 if nbElems > 0:
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200697 benchSection = Section(benchName)
698 document.addSection(benchSection)
Christophe Favergeone15894e2020-05-14 07:25:53 +0200699 print("Process %s\n" % benchName)
Christophe Favergeone15894e2020-05-14 07:25:53 +0200700 allTypes = getExistingTypes(benchName)
701 # Add report for each type
702 for aTypeID in allTypes:
703 nbElems = getNbElemsInBenchAndTypeCmd(benchName,aTypeID)
704 if nbElems > 0:
705 typeName = getTypeName(aTypeID)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200706 typeSection = Section(typeName)
707 benchSection.addSection(typeSection)
Christophe Favergeone15894e2020-05-14 07:25:53 +0200708 ## Add report for each compiler
709 allCompilers = getExistingCompiler(benchName,aTypeID)
710 for compiler in allCompilers:
711 #print(compiler)
712 nbElems = getNbElemsInBenchAndTypeAndCompilerCmd(benchName,compiler,aTypeID)
713 # Print test results for table, type, compiler
714 if nbElems > 0:
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200715 compilerSection = Section("%s (%s)" % compiler)
716 typeSection.addSection(compilerSection)
Christophe Favergeone15894e2020-05-14 07:25:53 +0200717 cols,vals=getColNamesAndData(benchName,compiler,aTypeID)
718 names=getTestNames(benchName,compiler,aTypeID)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200719 formatTableByCore(compilerSection,names,cols,vals)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200720
721
722
723
724
725try:
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200726 benchtables=getBenchTables()
Christophe Favergeone15894e2020-05-14 07:25:53 +0200727 theDate = getrunIDDate(runid)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200728 document = Document(runid,theDate)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200729 for bench in benchtables:
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200730 addReportFor(document,bench)
731 with open(args.o,"w") as output:
732 if args.t=="md":
733 document.accept(Markdown(output))
734 if args.t=="html":
735 document.accept(HTML(output))
736
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200737finally:
738 c.close()
739
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200740
741
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200742