extractDb.py 23 KB

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