Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 1 | import argparse |
| 2 | import sqlite3 |
| 3 | import re |
| 4 | import pandas as pd |
| 5 | import numpy as np |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 6 | from TestScripts.doc.Structure import * |
| 7 | from TestScripts.doc.Format import * |
Christophe Favergeon | 66de4ac | 2020-07-31 13:38:09 +0200 | [diff] [blame] | 8 | import os.path |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 9 | |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 10 | runidCMD = "runid = ?" |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 11 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 12 | # Command to get last runid |
| 13 | lastID="""SELECT runid FROM RUN ORDER BY runid DESC LIMIT 1 |
| 14 | """ |
| 15 | |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 16 | # Command to get last runid and date |
| 17 | lastIDAndDate="""SELECT date FROM RUN WHERE runid=? |
| 18 | """ |
| 19 | |
Christophe Favergeon | fe27d87 | 2020-07-31 07:20:18 +0200 | [diff] [blame] | 20 | # Command to get last runid |
| 21 | runIDDetails="""SELECT distinct core FROM %s |
| 22 | INNER JOIN CORE USING(coreid) |
| 23 | WHERE %s |
| 24 | """ |
| 25 | |
Christophe Favergeon | 0e0449a | 2020-07-28 09:44:14 +0200 | [diff] [blame] | 26 | def joinit(iterable, delimiter): |
| 27 | # Intersperse a delimiter between element of a list |
| 28 | it = iter(iterable) |
| 29 | yield next(it) |
| 30 | for x in it: |
| 31 | yield delimiter |
| 32 | yield x |
| 33 | |
| 34 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 35 | def getLastRunID(): |
| 36 | r=c.execute(lastID) |
| 37 | return(int(r.fetchone()[0])) |
| 38 | |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 39 | def getrunIDDate(forID): |
| 40 | r=c.execute(lastIDAndDate,(forID,)) |
| 41 | return(r.fetchone()[0]) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 42 | |
Christophe Favergeon | fe27d87 | 2020-07-31 07:20:18 +0200 | [diff] [blame] | 43 | |
| 44 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 45 | runid = 1 |
| 46 | |
| 47 | parser = argparse.ArgumentParser(description='Generate summary benchmarks') |
| 48 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 49 | parser.add_argument('-b', nargs='?',type = str, default="bench.db", help="Database") |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 50 | parser.add_argument('-o', nargs='?',type = str, default="full.md", help="Full summary") |
| 51 | parser.add_argument('-r', action='store_true', help="Regression database") |
Christophe Favergeon | fe27d87 | 2020-07-31 07:20:18 +0200 | [diff] [blame] | 52 | parser.add_argument('-t', nargs='?',type = str, default="md", help="type md or html") |
| 53 | parser.add_argument('-byc', action='store_true', help="Result oganized by Compiler") |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 54 | parser.add_argument('-g', action='store_true', help="Include graphs in regression report") |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 55 | |
Christophe Favergeon | fe27d87 | 2020-07-31 07:20:18 +0200 | [diff] [blame] | 56 | parser.add_argument('-details', action='store_true', help="Details about runids") |
| 57 | parser.add_argument('-lastid', action='store_true', help="Get last ID") |
Christophe Favergeon | 66de4ac | 2020-07-31 13:38:09 +0200 | [diff] [blame] | 58 | parser.add_argument('-comments', nargs='?',type = str, default="comments.txt", help="Comment section") |
Christophe Favergeon | fe27d87 | 2020-07-31 07:20:18 +0200 | [diff] [blame] | 59 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 60 | # For runid or runid range |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 61 | parser.add_argument('others', nargs=argparse.REMAINDER,help="Run ID") |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 62 | |
| 63 | args = parser.parse_args() |
| 64 | |
| 65 | c = sqlite3.connect(args.b) |
| 66 | |
| 67 | if args.others: |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 68 | if len(args.others) == 1: |
Christophe Favergeon | 0e0449a | 2020-07-28 09:44:14 +0200 | [diff] [blame] | 69 | if re.search(r'[,]',args.others[0]): |
| 70 | runidval=tuple([int(x) for x in args.others[0].split(",")]) |
| 71 | runidCMD=["runid == ?" for x in runidval] |
| 72 | runidCMD = "".join(joinit(runidCMD," OR ")) |
Christophe Favergeon | 66de4ac | 2020-07-31 13:38:09 +0200 | [diff] [blame] | 73 | runidHeader="".join(joinit([str(x) for x in runidval]," , ")) |
Christophe Favergeon | 0e0449a | 2020-07-28 09:44:14 +0200 | [diff] [blame] | 74 | runidCMD = "(" + runidCMD + ")" |
| 75 | else: |
| 76 | runid=int(args.others[0]) |
Christophe Favergeon | 66de4ac | 2020-07-31 13:38:09 +0200 | [diff] [blame] | 77 | runidHeader="%d" % runid |
Christophe Favergeon | 0e0449a | 2020-07-28 09:44:14 +0200 | [diff] [blame] | 78 | runidval = (runid,) |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 79 | else: |
| 80 | runidCMD = "runid >= ? AND runid <= ?" |
| 81 | runid=int(args.others[1]) |
| 82 | runidLOW=int(args.others[0]) |
| 83 | runidval = (runidLOW,runid) |
Christophe Favergeon | 66de4ac | 2020-07-31 13:38:09 +0200 | [diff] [blame] | 84 | runidHeader="%d <= runid <= %d" % runidval |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 85 | else: |
| 86 | runid=getLastRunID() |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 87 | print("Last run ID = %d\n" % runid) |
| 88 | runidval=(runid,) |
Christophe Favergeon | 66de4ac | 2020-07-31 13:38:09 +0200 | [diff] [blame] | 89 | runidHeader="%d" % runid |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 90 | |
Christophe Favergeon | fe27d87 | 2020-07-31 07:20:18 +0200 | [diff] [blame] | 91 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 92 | # We extract data only from data tables |
| 93 | # Those tables below are used for descriptions |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 94 | REMOVETABLES=['TESTNAME','TESTDATE','RUN','CORE', 'PLATFORM', 'COMPILERKIND', 'COMPILER', 'TYPE', 'CATEGORY', 'CONFIG'] |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 95 | |
| 96 | # This is assuming the database is generated by the regression script |
| 97 | # So platform is the same for all benchmarks. |
| 98 | # Category and type is coming from the test name in the yaml |
| 99 | # So no need to add this information here |
| 100 | # Name is removed here because it is added at the beginning |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 101 | REMOVECOLUMNS=['runid','name','type','platform','category','coredef','OPTIMIZED','HARDFP','FASTMATH','NEON','HELIUM','UNROLL','ROUNDING','DATE','compilerkindid','date','categoryid', 'ID', 'platformid', 'coreid', 'compilerid', 'typeid'] |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 102 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 103 | REMOVECOLUMNSFORHISTORY=['Regression','MAXREGCOEF','name','type','platform','category','coredef','OPTIMIZED','HARDFP','FASTMATH','NEON','HELIUM','UNROLL','ROUNDING','DATE','compilerkindid','date','categoryid', 'ID', 'platformid', 'coreid', 'compilerid', 'typeid'] |
| 104 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 105 | # Get existing benchmark tables |
| 106 | def getBenchTables(): |
| 107 | r=c.execute("SELECT name FROM sqlite_master WHERE type='table'") |
| 108 | benchtables=[] |
| 109 | for table in r: |
| 110 | if not table[0] in REMOVETABLES: |
| 111 | benchtables.append(table[0]) |
| 112 | return(benchtables) |
| 113 | |
| 114 | # get existing types in a table |
| 115 | def getExistingTypes(benchTable): |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 116 | r=c.execute("select distinct typeid from %s order by typeid desc" % benchTable).fetchall() |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 117 | result=[x[0] for x in r] |
| 118 | return(result) |
| 119 | |
Christophe Favergeon | fe27d87 | 2020-07-31 07:20:18 +0200 | [diff] [blame] | 120 | def getrunIDDetails(): |
| 121 | tables=getBenchTables() |
| 122 | r=[] |
| 123 | for table in tables: |
| 124 | r += [x[0] for x in c.execute(runIDDetails % (table,runidCMD),runidval).fetchall()] |
| 125 | r=list(set(r)) |
| 126 | print(r) |
| 127 | |
| 128 | if args.lastid: |
| 129 | quit() |
| 130 | |
| 131 | if args.details: |
| 132 | getrunIDDetails() |
| 133 | quit() |
| 134 | |
| 135 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 136 | # Get compilers from specific type and table |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 137 | allCompilers="""select distinct compilerid from %s WHERE typeid=?""" |
| 138 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 139 | # Get compilers from specific type and table |
| 140 | allCores="""select distinct coreid from %s WHERE typeid=?""" |
| 141 | |
| 142 | |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 143 | compilerDesc="""select compiler,version from COMPILER |
| 144 | INNER JOIN COMPILERKIND USING(compilerkindid) WHERE compilerid=?""" |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 145 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 146 | coreDesc="""select core from CORE WHERE coreid=?""" |
| 147 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 148 | # Get existing compiler in a table for a specific type |
| 149 | # (In case report is structured by types) |
| 150 | def getExistingCompiler(benchTable,typeid): |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 151 | r=c.execute(allCompilers % benchTable,(typeid,)).fetchall() |
| 152 | return([x[0] for x in r]) |
| 153 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 154 | def getExistingCores(benchTable,typeid): |
| 155 | r=c.execute(allCores % benchTable,(typeid,)).fetchall() |
| 156 | return([x[0] for x in r]) |
| 157 | |
| 158 | |
| 159 | |
| 160 | def getCoreDesc(compilerid): |
| 161 | r=c.execute(coreDesc,(compilerid,)).fetchone() |
| 162 | return(r) |
| 163 | |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 164 | def getCompilerDesc(compilerid): |
| 165 | r=c.execute(compilerDesc,(compilerid,)).fetchone() |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 166 | return(r) |
| 167 | |
| 168 | # Get type name from type id |
| 169 | def getTypeName(typeid): |
| 170 | r=c.execute("select type from TYPE where typeid=?",(typeid,)).fetchone() |
| 171 | return(r[0]) |
| 172 | |
| 173 | # Diff of 2 lists |
| 174 | def diff(first, second): |
| 175 | second = set(second) |
| 176 | return [item for item in first if item not in second] |
| 177 | |
| 178 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 179 | # Command to get data for specific core |
| 180 | # and type |
| 181 | historyCmd="""select %s from %s |
| 182 | INNER JOIN CATEGORY USING(categoryid) |
| 183 | INNER JOIN PLATFORM USING(platformid) |
| 184 | INNER JOIN CORE USING(coreid) |
| 185 | INNER JOIN COMPILER USING(compilerid) |
| 186 | INNER JOIN COMPILERKIND USING(compilerkindid) |
| 187 | INNER JOIN TYPE USING(typeid) |
| 188 | INNER JOIN TESTNAME USING(testnameid) |
| 189 | WHERE compilerid=? AND coreid=? AND typeid = ? AND ID = ? AND runid > (? - 10) |
| 190 | """ |
| 191 | |
| 192 | compilersForHistory="""select distinct compilerid,compiler,version from %s |
| 193 | INNER JOIN COMPILER USING(compilerid) |
| 194 | INNER JOIN COMPILERKIND USING(compilerkindid) |
| 195 | WHERE coreid=? AND typeid = ? AND ID = ? AND runid > (? - 10) |
| 196 | """ |
| 197 | |
| 198 | # Command to get data for specific core |
| 199 | # and type |
| 200 | benchCmdForCore="""select %s from %s |
| 201 | INNER JOIN CATEGORY USING(categoryid) |
| 202 | INNER JOIN PLATFORM USING(platformid) |
| 203 | INNER JOIN CORE USING(coreid) |
| 204 | INNER JOIN COMPILER USING(compilerid) |
| 205 | INNER JOIN COMPILERKIND USING(compilerkindid) |
| 206 | INNER JOIN TYPE USING(typeid) |
| 207 | INNER JOIN TESTNAME USING(testnameid) |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 208 | WHERE coreid=? AND typeid = ? AND %s |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 209 | """ |
| 210 | |
| 211 | coresForHistory="""select distinct coreid,core from %s |
| 212 | INNER JOIN CORE USING(coreid) |
| 213 | WHERE compilerid=? AND typeid = ? AND ID = ? AND runid > (? - 10) |
| 214 | """ |
| 215 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 216 | # Command to get data for specific compiler |
| 217 | # and type |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 218 | benchCmdForCompiler="""select %s from %s |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 219 | INNER JOIN CATEGORY USING(categoryid) |
| 220 | INNER JOIN PLATFORM USING(platformid) |
| 221 | INNER JOIN CORE USING(coreid) |
| 222 | INNER JOIN COMPILER USING(compilerid) |
| 223 | INNER JOIN COMPILERKIND USING(compilerkindid) |
| 224 | INNER JOIN TYPE USING(typeid) |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 225 | INNER JOIN TESTNAME USING(testnameid) |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 226 | WHERE compilerid=? AND typeid = ? AND %s |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 227 | """ |
| 228 | |
| 229 | # Command to get test names for specific compiler |
| 230 | # and type |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 231 | benchNamesForCore="""select distinct ID,name from %s |
| 232 | INNER JOIN COMPILER USING(compilerid) |
| 233 | INNER JOIN COMPILERKIND USING(compilerkindid) |
| 234 | INNER JOIN TYPE USING(typeid) |
| 235 | INNER JOIN TESTNAME USING(testnameid) |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 236 | WHERE coreid=? AND typeid = ? AND %s |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 237 | """ |
| 238 | # Command to get test names for specific compiler |
| 239 | # and type |
| 240 | benchNamesForCompiler="""select distinct ID,name from %s |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 241 | INNER JOIN COMPILER USING(compilerid) |
| 242 | INNER JOIN COMPILERKIND USING(compilerkindid) |
| 243 | INNER JOIN TYPE USING(typeid) |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 244 | INNER JOIN TESTNAME USING(testnameid) |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 245 | WHERE compilerid=? AND typeid = ? AND %s |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 246 | """ |
| 247 | |
| 248 | # Command to get columns for specific table |
| 249 | benchCmdColumns="""select * from %s |
| 250 | INNER JOIN CATEGORY USING(categoryid) |
| 251 | INNER JOIN PLATFORM USING(platformid) |
| 252 | INNER JOIN CORE USING(coreid) |
| 253 | INNER JOIN COMPILER USING(compilerid) |
| 254 | INNER JOIN COMPILERKIND USING(compilerkindid) |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 255 | INNER JOIN TESTNAME USING(testnameid) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 256 | INNER JOIN TYPE USING(typeid) |
| 257 | """ |
| 258 | |
| 259 | def joinit(iterable, delimiter): |
| 260 | it = iter(iterable) |
| 261 | yield next(it) |
| 262 | for x in it: |
| 263 | yield delimiter |
| 264 | yield x |
| 265 | |
| 266 | # Is not a column name finishing by id |
| 267 | # (often primary key for thetable) |
| 268 | def isNotIDColumn(col): |
| 269 | if re.match(r'^.*id$',col): |
| 270 | return(False) |
| 271 | else: |
| 272 | return(True) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 273 | |
| 274 | # Get test names |
| 275 | # for specific typeid and core (for the data) |
| 276 | def getTestNamesForCore(benchTable,core,typeid): |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 277 | vals=(core,typeid) + runidval |
| 278 | result=c.execute(benchNamesForCore % (benchTable,runidCMD),vals).fetchall() |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 279 | names=[(x[0],x[1]) for x in list(result)] |
| 280 | return(names) |
| 281 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 282 | # Get test names |
| 283 | # for specific typeid and compiler (for the data) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 284 | def getTestNamesForCompiler(benchTable,comp,typeid): |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 285 | vals=(comp,typeid) + runidval |
| 286 | result=c.execute(benchNamesForCompiler % (benchTable,runidCMD),vals).fetchall() |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 287 | names=[(x[0],x[1]) for x in list(result)] |
| 288 | return(names) |
| 289 | |
| 290 | # Command to get data for specific core |
| 291 | # and type |
| 292 | nbElemsInBenchAndTypeAndCoreCmd="""select count(*) from %s |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 293 | WHERE coreid=? AND typeid = ? AND %s |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 294 | """ |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 295 | |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 296 | # Command to get data for specific compiler |
| 297 | # and type |
| 298 | nbElemsInBenchAndTypeAndCompilerCmd="""select count(*) from %s |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 299 | WHERE compilerid=? AND typeid = ? AND %s |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 300 | """ |
| 301 | |
| 302 | nbElemsInBenchAndTypeCmd="""select count(*) from %s |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 303 | WHERE typeid = ? AND %s |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 304 | """ |
| 305 | |
| 306 | nbElemsInBenchCmd="""select count(*) from %s |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 307 | WHERE %s |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 308 | """ |
| 309 | |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 310 | categoryName="""select distinct category from %s |
| 311 | INNER JOIN CATEGORY USING(categoryid) |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 312 | WHERE %s |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 313 | """ |
| 314 | |
| 315 | def getCategoryName(benchTable,runid): |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 316 | result=c.execute(categoryName % (benchTable,runidCMD),runidval).fetchone() |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 317 | return(result[0]) |
| 318 | |
Christophe Favergeon | 4f75070 | 2020-05-13 15:56:15 +0200 | [diff] [blame] | 319 | # Get nb elems in a table |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 320 | def getNbElemsInBenchAndTypeAndCoreCmd(benchTable,coreid,typeid): |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 321 | vals=(coreid,typeid) + runidval |
| 322 | result=c.execute(nbElemsInBenchAndTypeAndCoreCmd % (benchTable,runidCMD),vals).fetchone() |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 323 | return(result[0]) |
| 324 | |
| 325 | # Get nb elems in a table |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 326 | def getNbElemsInBenchAndTypeAndCompilerCmd(benchTable,comp,typeid): |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 327 | vals=(comp,typeid) + runidval |
| 328 | result=c.execute(nbElemsInBenchAndTypeAndCompilerCmd % (benchTable,runidCMD),vals).fetchone() |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 329 | return(result[0]) |
| 330 | |
| 331 | def getNbElemsInBenchAndTypeCmd(benchTable,typeid): |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 332 | vals=(typeid,) + runidval |
| 333 | result=c.execute(nbElemsInBenchAndTypeCmd % (benchTable,runidCMD),vals).fetchone() |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 334 | return(result[0]) |
| 335 | |
| 336 | def getNbElemsInBenchCmd(benchTable): |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 337 | result=c.execute(nbElemsInBenchCmd % (benchTable,runidCMD),runidval).fetchone() |
Christophe Favergeon | 4f75070 | 2020-05-13 15:56:15 +0200 | [diff] [blame] | 338 | return(result[0]) |
| 339 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 340 | # Get names of columns and data for a table |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 341 | # for specific typeid and coreid (for the data) |
| 342 | def getColNamesAndHistory(benchTable,compiler,core,typeid,testid): |
| 343 | cursor=c.cursor() |
| 344 | result=cursor.execute(benchCmdColumns % (benchTable)) |
| 345 | cols= [member[0] for member in cursor.description] |
| 346 | keepCols = ['name','runid'] + [c for c in diff(cols , REMOVECOLUMNSFORHISTORY) if isNotIDColumn(c)] |
| 347 | keepColsStr = "".join(joinit(keepCols,",")) |
| 348 | vals=(compiler,core,typeid,testid,runid) |
| 349 | result=cursor.execute(historyCmd % (keepColsStr,benchTable),vals) |
| 350 | vals =np.array([list(x) for x in list(result)]) |
| 351 | return(keepCols,vals) |
| 352 | |
| 353 | # Get names of columns and data for a table |
| 354 | # for specific typeid and coreid (for the data) |
| 355 | def getColNamesAndDataForCore(benchTable,core,typeid): |
| 356 | cursor=c.cursor() |
| 357 | result=cursor.execute(benchCmdColumns % (benchTable)) |
| 358 | cols= [member[0] for member in cursor.description] |
| 359 | keepCols = ['name'] + [c for c in diff(cols , REMOVECOLUMNS) if isNotIDColumn(c)] |
| 360 | keepColsStr = "".join(joinit(keepCols,",")) |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 361 | vals=(core,typeid) + runidval |
| 362 | result=cursor.execute(benchCmdForCore % (keepColsStr,benchTable,runidCMD),vals) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 363 | vals =np.array([list(x) for x in list(result)]) |
| 364 | return(keepCols,vals) |
| 365 | |
| 366 | |
| 367 | # Get names of columns and data for a table |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 368 | # for specific typeid and compiler (for the data) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 369 | def getColNamesAndDataForCompiler(benchTable,comp,typeid): |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 370 | cursor=c.cursor() |
| 371 | result=cursor.execute(benchCmdColumns % (benchTable)) |
| 372 | cols= [member[0] for member in cursor.description] |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 373 | keepCols = ['name'] + [c for c in diff(cols , REMOVECOLUMNS) if isNotIDColumn(c)] |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 374 | keepColsStr = "".join(joinit(keepCols,",")) |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 375 | vals=(comp,typeid) + runidval |
| 376 | result=cursor.execute(benchCmdForCompiler % (keepColsStr,benchTable,runidCMD),vals) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 377 | vals =np.array([list(x) for x in list(result)]) |
| 378 | return(keepCols,vals) |
| 379 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 380 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 381 | |
| 382 | PARAMS=["NB","NumTaps", "NBA", "NBB", "Factor", "NumStages","VECDIM","NBR","NBC","NBI","IFFT", "BITREV"] |
| 383 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 384 | def regressionTableFor(byname,name,section,ref,toSort,indexCols,field): |
| 385 | data=ref.pivot_table(index=indexCols, columns=byname, |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 386 | values=[field], aggfunc='first') |
| 387 | |
| 388 | data=data.sort_values(toSort) |
| 389 | |
| 390 | cores = [c[1] for c in list(data.columns)] |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 391 | columns = diff(indexCols,['name']) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 392 | |
Christophe Favergeon | 34d313a | 2020-05-14 15:09:41 +0200 | [diff] [blame] | 393 | dataTable=Table(columns,cores) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 394 | section.addContent(dataTable) |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 395 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 396 | dataForFunc=data.loc[name] |
| 397 | if type(dataForFunc) is pd.DataFrame: |
Christophe Favergeon | 0dcf9a1 | 2020-05-27 15:55:27 +0200 | [diff] [blame] | 398 | bars={'cols':columns,'cores':cores,'data':[]} |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 399 | for row in dataForFunc.itertuples(): |
| 400 | row=list(row) |
| 401 | if type(row[0]) is int: |
| 402 | row=[row[0]] + row[1:] |
| 403 | else: |
| 404 | row=list(row[0]) + row[1:] |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 405 | if field=="MAXREGCOEF": |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 406 | newrow = row |
| 407 | newrow[len(columns):] = [("%.3f" % x) for x in row[len(columns):]] |
| 408 | row=newrow |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 409 | dataTable.addRow(row) |
Christophe Favergeon | 0dcf9a1 | 2020-05-27 15:55:27 +0200 | [diff] [blame] | 410 | bars['data'].append(row) |
| 411 | return(bars) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 412 | else: |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 413 | if field=="MAXREGCOEF": |
| 414 | dataForFunc=[("%.3f" % x) for x in dataForFunc] |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 415 | dataTable.addRow(dataForFunc) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 416 | return(list(zip(cores,dataForFunc))) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 417 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 418 | def formatColumnName(c): |
| 419 | return("".join(joinit(c,":"))) |
| 420 | |
| 421 | def getCoresForHistory(benchTable,compilerid,typeid,testid,runid): |
| 422 | vals=(compilerid,typeid,testid,runid) |
| 423 | result=c.execute(coresForHistory % benchTable,vals).fetchall() |
| 424 | ids=[(x[0],x[1]) for x in list(result)] |
| 425 | return(ids) |
| 426 | |
| 427 | def getCompilerForHistory(benchTable,coreid,typeid,testid,runid): |
| 428 | vals=(coreid,typeid,testid,runid) |
| 429 | result=c.execute(compilersForHistory % benchTable,vals).fetchall() |
| 430 | ids=[(x[0],x[1],x[2]) for x in list(result)] |
| 431 | return(ids) |
| 432 | |
| 433 | def getHistory(desc,testid,indexCols): |
| 434 | benchName,sectionID,typeid,runid = desc |
| 435 | |
| 436 | #print(benchName) |
| 437 | #print(sectionID) |
| 438 | #print(typeid) |
| 439 | #print(testid) |
| 440 | columns = diff(indexCols,['name']) |
| 441 | #print(columns) |
| 442 | if args.byc: |
| 443 | coreid=sectionID |
| 444 | compilerids=getCompilerForHistory(benchName,coreid,typeid,testid,runid) |
| 445 | series={} |
| 446 | for compilerid,compilername,version in compilerids: |
| 447 | result=getColNamesAndHistory(benchName,compilerid,coreid,typeid,testid) |
| 448 | #print("%s:%s" % (compilername,version)) |
| 449 | maxpos = result[0].index('MAX') |
| 450 | lrunid = result[0].index('runid') |
| 451 | r=[[int(x[lrunid]),int(x[maxpos])] for x in result[1:][0]] |
| 452 | series[corename]=r |
| 453 | hist=History(series,runid) |
| 454 | return(hist) |
| 455 | else: |
| 456 | compilerid=sectionID |
| 457 | coreids = getCoresForHistory(benchName,compilerid,typeid,testid,runid) |
| 458 | series={} |
| 459 | for coreid,corename in coreids: |
| 460 | result=getColNamesAndHistory(benchName,compilerid,coreid,typeid,testid) |
| 461 | #print(corename) |
| 462 | maxpos = result[0].index('MAX') |
| 463 | corepos = result[0].index('core') |
| 464 | lrunid = result[0].index('runid') |
| 465 | r=[[int(x[lrunid]),int(x[maxpos])] for x in result[1:][0]] |
| 466 | series[corename]=r |
| 467 | hist=History(series,runid) |
| 468 | return(hist) |
| 469 | |
| 470 | def formatTableBy(desc,byname,section,typeSection,testNames,cols,vals): |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 471 | if vals.size != 0: |
| 472 | ref=pd.DataFrame(vals,columns=cols) |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 473 | toSort=["name"] |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 474 | |
| 475 | for param in PARAMS: |
| 476 | if param in ref.columns: |
| 477 | ref[param]=pd.to_numeric(ref[param]) |
| 478 | toSort.append(param) |
| 479 | if args.r: |
| 480 | # Regression table |
| 481 | ref['MAX']=pd.to_numeric(ref['MAX']) |
| 482 | ref['MAXREGCOEF']=pd.to_numeric(ref['MAXREGCOEF']) |
| 483 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 484 | indexCols=diff(cols,byname + ['Regression','MAXREGCOEF','MAX'] + section) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 485 | valList = ['Regression'] |
| 486 | else: |
| 487 | ref['CYCLES']=pd.to_numeric(ref['CYCLES']) |
| 488 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 489 | indexCols=diff(cols,byname + ['CYCLES'] + section) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 490 | valList = ['CYCLES'] |
| 491 | |
| 492 | |
| 493 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 494 | for testid,name in testNames: |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 495 | if args.r: |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 496 | testSection = Section(name) |
| 497 | typeSection.addSection(testSection) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 498 | |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 499 | maxCyclesSection = Section("Max cycles") |
| 500 | testSection.addSection(maxCyclesSection) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 501 | theCycles=regressionTableFor(byname,name,maxCyclesSection,ref,toSort,indexCols,'MAX') |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 502 | if args.g: |
| 503 | if type(theCycles) is dict: |
| 504 | nbParams=len(theCycles['cols']) |
| 505 | for bar in theCycles['data']: |
| 506 | params=bar[0:nbParams] |
| 507 | values=bar[nbParams:] |
| 508 | title=[("%s=%s" % x) for x in list(zip(theCycles['cols'],params))] |
| 509 | title="".join(joinit(title," ")) |
| 510 | sec=Section(title) |
| 511 | maxCyclesSection.addSection(sec) |
| 512 | values=list(zip(theCycles['cores'],values)) |
| 513 | barChart=BarChart(values) |
| 514 | sec.addContent(barChart) |
| 515 | else: |
| 516 | #print(theCycles) |
| 517 | sec=Section("Graph") |
Christophe Favergeon | 0dcf9a1 | 2020-05-27 15:55:27 +0200 | [diff] [blame] | 518 | maxCyclesSection.addSection(sec) |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 519 | barChart=BarChart(theCycles) |
Christophe Favergeon | 0dcf9a1 | 2020-05-27 15:55:27 +0200 | [diff] [blame] | 520 | sec.addContent(barChart) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 521 | |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 522 | #history=getHistory(desc,testid,indexCols) |
| 523 | #testSection.addContent(history) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 524 | |
| 525 | regressionSection = Section("Regression") |
| 526 | testSection.addSection(regressionSection) |
| 527 | regressionTableFor(byname,name,regressionSection,ref,toSort,indexCols,'Regression') |
| 528 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 529 | |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 530 | maxRegCoefSection = Section("Max Reg Coef") |
| 531 | testSection.addSection(maxRegCoefSection) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 532 | regressionTableFor(byname,name,maxRegCoefSection,ref,toSort,indexCols,'MAXREGCOEF') |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 533 | |
| 534 | else: |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 535 | data=ref.pivot_table(index=indexCols, columns=byname, |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 536 | values=valList, aggfunc='first') |
| 537 | |
| 538 | data=data.sort_values(toSort) |
| 539 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 540 | #print(list(data.columns)) |
| 541 | columnsID = [formatColumnName(c[1:]) for c in list(data.columns)] |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 542 | columns = diff(indexCols,['name']) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 543 | |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 544 | testSection = Section(name) |
| 545 | typeSection.addSection(testSection) |
| 546 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 547 | dataTable=Table(columns,columnsID) |
| 548 | testSection.addContent(dataTable) |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 549 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 550 | dataForFunc=data.loc[name] |
| 551 | if type(dataForFunc) is pd.DataFrame: |
| 552 | for row in dataForFunc.itertuples(): |
| 553 | row=list(row) |
| 554 | if type(row[0]) is int: |
| 555 | row=[row[0]] + row[1:] |
| 556 | else: |
| 557 | row=list(row[0]) + row[1:] |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 558 | dataTable.addRow(row) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 559 | else: |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 560 | dataTable.addRow(dataForFunc) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 561 | |
| 562 | # Add a report for each table |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 563 | def addReportFor(document,runid,benchName): |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 564 | nbElems = getNbElemsInBenchCmd(benchName) |
| 565 | if nbElems > 0: |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 566 | categoryName = getCategoryName(benchName,runid) |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 567 | benchSection = Section(categoryName) |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 568 | document.addSection(benchSection) |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 569 | print("Process %s\n" % benchName) |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 570 | allTypes = getExistingTypes(benchName) |
| 571 | # Add report for each type |
| 572 | for aTypeID in allTypes: |
| 573 | nbElems = getNbElemsInBenchAndTypeCmd(benchName,aTypeID) |
| 574 | if nbElems > 0: |
| 575 | typeName = getTypeName(aTypeID) |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 576 | typeSection = Section(typeName) |
| 577 | benchSection.addSection(typeSection) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 578 | if args.byc: |
| 579 | ## Add report for each core |
| 580 | allCores = getExistingCores(benchName,aTypeID) |
| 581 | for core in allCores: |
| 582 | #print(core) |
| 583 | nbElems = getNbElemsInBenchAndTypeAndCoreCmd(benchName,core,aTypeID) |
| 584 | # Print test results for table, type, compiler |
| 585 | if nbElems > 0: |
| 586 | coreName=getCoreDesc(core) |
| 587 | coreSection = Section("%s" % coreName) |
| 588 | typeSection.addSection(coreSection) |
| 589 | cols,vals=getColNamesAndDataForCore(benchName,core,aTypeID) |
| 590 | desc=(benchName,core,aTypeID,runid) |
| 591 | names=getTestNamesForCore(benchName,core,aTypeID) |
| 592 | formatTableBy(desc,['compiler','version'],['core'],coreSection,names,cols,vals) |
| 593 | else: |
| 594 | ## Add report for each compiler |
| 595 | allCompilers = getExistingCompiler(benchName,aTypeID) |
| 596 | for compiler in allCompilers: |
| 597 | #print(compiler) |
| 598 | nbElems = getNbElemsInBenchAndTypeAndCompilerCmd(benchName,compiler,aTypeID) |
| 599 | # Print test results for table, type, compiler |
| 600 | if nbElems > 0: |
| 601 | compilerName,version=getCompilerDesc(compiler) |
| 602 | compilerSection = Section("%s (%s)" % (compilerName,version)) |
| 603 | typeSection.addSection(compilerSection) |
| 604 | cols,vals=getColNamesAndDataForCompiler(benchName,compiler,aTypeID) |
| 605 | desc=(benchName,compiler,aTypeID,runid) |
| 606 | names=getTestNamesForCompiler(benchName,compiler,aTypeID) |
| 607 | formatTableBy(desc,['core'],['version','compiler'],compilerSection,names,cols,vals) |
| 608 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 609 | |
| 610 | |
| 611 | |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 612 | toc=[Hierarchy("BasicMathsBenchmarks"), |
| 613 | Hierarchy("ComplexMathsBenchmarks"), |
| 614 | Hierarchy("FastMath"), |
| 615 | Hierarchy("Filters", |
| 616 | [Hierarchy("FIR"), |
| 617 | Hierarchy("BIQUAD"), |
| 618 | Hierarchy("DECIM"), |
| 619 | Hierarchy("MISC")]), |
| 620 | |
| 621 | Hierarchy("Support Functions", |
| 622 | [Hierarchy("Support"), |
| 623 | Hierarchy("SupportBar")]), |
| 624 | |
| 625 | Hierarchy("Matrix Operations" , |
| 626 | [Hierarchy("Binary"), |
| 627 | Hierarchy("Unary")]), |
| 628 | Hierarchy("Transform"), |
| 629 | |
| 630 | ] |
| 631 | |
| 632 | processed=[] |
| 633 | |
Christophe Favergeon | 66de4ac | 2020-07-31 13:38:09 +0200 | [diff] [blame] | 634 | def addComments(document): |
| 635 | if os.path.exists(args.comments): |
| 636 | section=Section("Measurement Context") |
| 637 | |
| 638 | document.addSection(section) |
| 639 | para="" |
| 640 | with open(args.comments,"r") as r: |
| 641 | for l in r: |
| 642 | if l.strip(): |
| 643 | para += l |
| 644 | else: |
| 645 | section.addContent(Text(para)) |
| 646 | para="" |
| 647 | if para: |
| 648 | section.addContent(Text(para)) |
| 649 | |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 650 | def createDoc(document,sections,benchtables): |
| 651 | global processed |
| 652 | for s in sections: |
| 653 | if s.name in benchtables: |
| 654 | addReportFor(document,runid,s.name) |
| 655 | processed.append(s.name) |
| 656 | else: |
| 657 | section=Section(s.name) |
| 658 | document.addSection(section) |
| 659 | createDoc(section,s.sections,benchtables) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 660 | |
| 661 | try: |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 662 | benchtables=getBenchTables() |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 663 | theDate = getrunIDDate(runid) |
Christophe Favergeon | 66de4ac | 2020-07-31 13:38:09 +0200 | [diff] [blame] | 664 | document = Document(runidHeader) |
| 665 | |
| 666 | addComments(document) |
| 667 | |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 668 | createDoc(document,toc,benchtables) |
Christophe Favergeon | 66de4ac | 2020-07-31 13:38:09 +0200 | [diff] [blame] | 669 | |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 670 | misc=Section("Miscellaneous") |
| 671 | document.addSection(misc) |
| 672 | remaining=diff(benchtables,processed) |
| 673 | for bench in remaining: |
| 674 | addReportFor(misc,runid,bench) |
| 675 | |
| 676 | #for bench in benchtables: |
| 677 | # addReportFor(document,bench) |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 678 | with open(args.o,"w") as output: |
| 679 | if args.t=="md": |
| 680 | document.accept(Markdown(output)) |
| 681 | if args.t=="html": |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 682 | document.accept(HTML(output,args.r)) |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 683 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 684 | finally: |
| 685 | c.close() |
| 686 | |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 687 | |
| 688 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 689 | |