From 3129c4e1c290d71da21ccbb97b83d52813d98a90 Mon Sep 17 00:00:00 2001 From: Christophe Favergeon Date: Fri, 31 Jul 2020 13:38:09 +0200 Subject: [PATCH] CMSIS-DSP: Improve formatting scripts --- Testing/TestScripts/doc/Format.py | 72 ++++++++++++++++++++++++++-- Testing/TestScripts/doc/Structure.py | 9 ++-- Testing/createDb.sql | 13 +++-- Testing/extractDb.py | 29 ++++++++++- 4 files changed, 109 insertions(+), 14 deletions(-) diff --git a/Testing/TestScripts/doc/Format.py b/Testing/TestScripts/doc/Format.py index b4d4a622..dffb3394 100755 --- a/Testing/TestScripts/doc/Format.py +++ b/Testing/TestScripts/doc/Format.py @@ -1,4 +1,8 @@ import math +from datetime import date + + + def joinit(iterable, delimiter): it = iter(iterable) yield next(it) @@ -6,6 +10,28 @@ def joinit(iterable, delimiter): yield delimiter yield x +# To format, in HTML, the cores in the right order. +# First we order tje categories +# Then we order the cores in each category +# The final ORDEREDCORES is what is used +# to order tjhe values +# Since some cores may be missing, each atble display +# is computing a rstricted ordered core list with only the available cores. +CORTEXCATEGORIES=["Cortex-M","Cortex-R","Cortex-A"] +CORECATEGORIES={"Cortex-M":["m0","m4", "m7", "m33" , "m55 scalar", "m55 mve"], +"Cortex-R":["r8","r52"], +"Cortex-A":["a32"] +} +ORDEREDCORES=[] +for cat in CORTEXCATEGORIES: + cores=[] + if cat in CORECATEGORIES: + for core in CORECATEGORIES[cat]: + cores.append(core) + else: + print("Error core %s not found" % cat) + quit() + ORDEREDCORES += cores class Markdown: def __init__(self,output): @@ -54,7 +80,7 @@ class Markdown: self._id = self._id - 1 def visitDocument(self,document): - self._output.write("Run number %d on %s\n" % (document.runid, str(document.date))) + self._output.write("Document generated frun run ids : %s\n" % document.runidHeader) def leaveDocument(self,document): pass @@ -439,6 +465,24 @@ class HTMLToc: def leaveDocument(self,document): self._output.write("%s\n" % script) +def permutation(ordered,unordered): + result=[] + restricted=[] + for c in ORDEREDCORES: + if c in unordered: + restricted.append(c) + + for c in unordered: + result.append(restricted.index(c)) + + return(result,restricted) + +def reorder(p,v): + result=[0 for x in v] + for val,i in zip(v,p): + result[i]=val + + return(result) class HTML: def __init__(self,output,regMode): @@ -486,7 +530,9 @@ myhist(thehdata%d,"#hi%d"); self._histID = self._histID + 1 def visitText(self,text): - pass + self._output.write("

\n") + self._output.write(text.text) + self._output.write("

\n") def visitTable(self,table): self._output.write("\n") @@ -498,7 +544,10 @@ myhist(thehdata%d,"#hi%d"); self._output.write("\n") - for col in table.cores: + + perm,restricted=permutation(ORDEREDCORES,table.cores) + + for col in restricted: if firstCore: self._output.write("\n") i = 0 + + row=list(row) + + #print(row) + + params=row[0:nbParams] + values=row[nbParams:] + + row = params + reorder(perm,values) + for elem in row: if i < nbParams: self._output.write("
") self._output.write(str(col)) self._output.write("") else: @@ -513,6 +562,16 @@ myhist(thehdata%d,"#hi%d"); for row in table.rows: self._output.write("
") @@ -549,7 +608,12 @@ myhist(thehdata%d,"#hi%d"); self._output.write("

ECPS Benchmark Regressions

\n") else: self._output.write("

ECPS Benchmark Summary

\n") - self._output.write("

Run number %d on %s

\n" % (document.runid, str(document.date))) + + self._output.write("

Document generated for run ids : %s

\n" % document.runidHeader) + today = date.today() + d2 = today.strftime("%B %d, %Y") + self._output.write("

Document generated on %s

\n" % d2) + self._output.write(barscript) def leaveDocument(self,document): diff --git a/Testing/TestScripts/doc/Structure.py b/Testing/TestScripts/doc/Structure.py index 50956ea8..6abd76ab 100755 --- a/Testing/TestScripts/doc/Structure.py +++ b/Testing/TestScripts/doc/Structure.py @@ -31,14 +31,13 @@ class Hierarchy: class Document: - def __init__(self,runid,date): - self._runid = runid - self._date = date + def __init__(self,runidHeader): + self._runidHeader = runidHeader self._sections = [] @property - def runid(self): - return(self._runid) + def runidHeader(self): + return(self._runidHeader) @property def date(self): diff --git a/Testing/createDb.sql b/Testing/createDb.sql index 1c74cc1e..2ef823dc 100755 --- a/Testing/createDb.sql +++ b/Testing/createDb.sql @@ -105,15 +105,22 @@ INSERT INTO CORE VALUES(12,"a9","ARMCA9"); INSERT INTO CORE VALUES(13,"a15","ARMCA15"); INSERT INTO CORE VALUES(14,"m55mvef","ARMv81MML_DSP_DP_MVE_FP"); + +# Second item is text as displayed in UI +# Third is CONFIGID generated by run script +# and different from COREID as was used before +# Above we have entries with COREIDs but it is +# no more used INSERT INTO CORE VALUES(15,"m0","M0"); INSERT INTO CORE VALUES(16,"m7","M7"); INSERT INTO CORE VALUES(17,"m33","M33"); INSERT INTO CORE VALUES(18,"m4","M4"); INSERT INTO CORE VALUES(19,"m55 mve","M55"); INSERT INTO CORE VALUES(20,"m55 scalar","M55SCALAR"); -INSERT INTO CORE VALUES(21,"r8","ARMCR8"); -INSERT INTO CORE VALUES(22,"r5","ARMCR5"); -INSERT INTO CORE VALUES(23,"a32","ARMCA32"); +INSERT INTO CORE VALUES(21,"r8","R8"); +INSERT INTO CORE VALUES(22,"r5","R5"); +INSERT INTO CORE VALUES(23,"a32","A32"); +INSERT INTO CORE VALUES(24,"r52","R52"); .quit diff --git a/Testing/extractDb.py b/Testing/extractDb.py index b3f72985..a7b9e948 100755 --- a/Testing/extractDb.py +++ b/Testing/extractDb.py @@ -5,7 +5,7 @@ import pandas as pd import numpy as np from TestScripts.doc.Structure import * from TestScripts.doc.Format import * - +import os.path runidCMD = "runid = ?" @@ -55,6 +55,7 @@ parser.add_argument('-g', action='store_true', help="Include graphs in regressio parser.add_argument('-details', action='store_true', help="Details about runids") parser.add_argument('-lastid', action='store_true', help="Get last ID") +parser.add_argument('-comments', nargs='?',type = str, default="comments.txt", help="Comment section") # For runid or runid range parser.add_argument('others', nargs=argparse.REMAINDER,help="Run ID") @@ -69,19 +70,23 @@ if args.others: runidval=tuple([int(x) for x in args.others[0].split(",")]) runidCMD=["runid == ?" for x in runidval] runidCMD = "".join(joinit(runidCMD," OR ")) + runidHeader="".join(joinit([str(x) for x in runidval]," , ")) runidCMD = "(" + runidCMD + ")" else: runid=int(args.others[0]) + runidHeader="%d" % runid runidval = (runid,) else: runidCMD = "runid >= ? AND runid <= ?" runid=int(args.others[1]) runidLOW=int(args.others[0]) runidval = (runidLOW,runid) + runidHeader="%d <= runid <= %d" % runidval else: runid=getLastRunID() print("Last run ID = %d\n" % runid) runidval=(runid,) + runidHeader="%d" % runid # We extract data only from data tables @@ -626,6 +631,22 @@ Hierarchy("Transform"), processed=[] +def addComments(document): + if os.path.exists(args.comments): + section=Section("Measurement Context") + + document.addSection(section) + para="" + with open(args.comments,"r") as r: + for l in r: + if l.strip(): + para += l + else: + section.addContent(Text(para)) + para="" + if para: + section.addContent(Text(para)) + def createDoc(document,sections,benchtables): global processed for s in sections: @@ -640,8 +661,12 @@ def createDoc(document,sections,benchtables): try: benchtables=getBenchTables() theDate = getrunIDDate(runid) - document = Document(runid,theDate) + document = Document(runidHeader) + + addComments(document) + createDoc(document,toc,benchtables) + misc=Section("Miscellaneous") document.addSection(misc) remaining=diff(benchtables,processed)