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