diff --git a/Testing/TestScripts/doc/Format.py b/Testing/TestScripts/doc/Format.py new file mode 100755 index 00000000..fc6102cf --- /dev/null +++ b/Testing/TestScripts/doc/Format.py @@ -0,0 +1,317 @@ +class Markdown: + def __init__(self,output): + self._id=0 + self._output = output + + # Write columns in markdown format + def writeColumns(self,cols): + colStr = "".join(joinit(cols,"|")) + self._output.write("|") + self._output.write(colStr) + self._output.write("|\n") + sepStr="".join(joinit([":-:" for x in cols],"|")) + self._output.write("|") + self._output.write(sepStr) + self._output.write("|\n") + + # Write row in markdown format + def writeRow(self,row): + row=[str(x) for x in row] + rowStr = "".join(joinit(row,"|")) + self._output.write("|") + self._output.write(rowStr) + self._output.write("|\n") + + def visitTable(self,table): + self.writeColumns(table.columns) + for row in table.rows: + self.writeRow(row) + + def visitSection(self,section): + self._id = self._id + 1 + header = "".join(["#" for i in range(self._id)]) + self._output.write("%s %s\n" % (header,section.name)) + + def leaveSection(self,section): + self._id = self._id - 1 + + def visitDocument(self,document): + self._output.write("Run number %d on %s\n" % (document.runid, str(document.date))) + + def leaveDocument(self,document): + pass + +styleSheet=""" + +""" + +script="""""" + + +class HTMLToc: + def __init__(self,output): + self._id=0 + self._sectionID = 0 + self._output = output + + + + def visitTable(self,table): + pass + + + def visitSection(self,section): + self._id = self._id + 1 + self._sectionID = self._sectionID + 1 + if section.hasChildren: + self._output.write("
  • %s\n" % (self._sectionID,section.name)) + self._output.write("
  • \n") + + self._id = self._id - 1 + + def visitDocument(self,document): + self._output.write("

    Table of content

    %s\n" % script) + + +class HTML: + def __init__(self,output,regMode): + self._id=0 + self._sectionID = 0 + self._output = output + self._regMode = regMode + + + + def visitTable(self,table): + self._output.write("\n") + self._output.write("\n") + self._output.write("\n") + firstCore = False + for col in table.params: + firstCore = True + self._output.write("\n") + for col in table.cores: + if firstCore: + self._output.write("\n") + firstCore = False + self._output.write("\n") + self._output.write("\n") + + nbParams = len(table.params) + for row in table.rows: + self._output.write("\n") + i = 0 + for elem in row: + if i < nbParams: + self._output.write("\n") + elif i == nbParams and nbParams != 0: + self._output.write("\n") + else: + self._output.write("\n") + i = i + 1 + self._output.write("\n") + self._output.write("
    ") + self._output.write(str(col)) + self._output.write("") + else: + self._output.write("") + self._output.write(str(col)) + self._output.write("
    ") + self._output.write(str(elem)) + self._output.write("") + self._output.write(str(elem)) + self._output.write("") + self._output.write(str(elem)) + self._output.write("
    \n") + + + def visitSection(self,section): + self._id = self._id + 1 + self._sectionID = self._sectionID + 1 + self._output.write("%s\n" % (self._id,self._sectionID,section.name,self._id)) + + def leaveSection(self,section): + self._id = self._id - 1 + + def visitDocument(self,document): + self._output.write(""" + + + +Benchmarks%s\n""" % styleSheet) + if self._regMode: + 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))) + + def leaveDocument(self,document): + document.accept(HTMLToc(self._output)) + + self._output.write("\n") + + diff --git a/Testing/TestScripts/doc/Structure.py b/Testing/TestScripts/doc/Structure.py new file mode 100755 index 00000000..bc59e7e6 --- /dev/null +++ b/Testing/TestScripts/doc/Structure.py @@ -0,0 +1,109 @@ + + +class Hierarchy: + def __init__(self,name,subsections=None): + self._parent = None + self._name=name + self._sections = [] + if subsections is not None: + for s in subsections: + self.addSection(s) + + @property + def parent(self): + return(self._parent) + + @property + def sections(self): + return(self._sections) + + def addSection(self,section): + self._sections.append(section) + + @property + def hasChildren(self): + return(len(self._sections)>0) + + @property + def name(self): + return(self._name) + + + +class Document: + def __init__(self,runid,date): + self._runid = runid + self._date = date + self._sections = [] + + @property + def runid(self): + return(self._runid) + + @property + def date(self): + return(self._date) + + @property + def sections(self): + return(self._sections) + + def addSection(self,section): + self._sections.append(section) + + def accept(self, visitor): + visitor.visitDocument(self) + for element in self._sections: + element.accept(visitor) + visitor.leaveDocument(self) + +class Section(Hierarchy): + def __init__(self,name): + super(Section, self).__init__(name) + self._tables = [] + + def addTable(self,table): + self._tables.append(table) + + @property + def hasContent(self): + return(len(self._tables) > 0 or any([x.hasContent for x in self.sections])) + + + def accept(self, visitor): + if self.hasContent: + visitor.visitSection(self) + for element in self.sections: + element.accept(visitor) + for element in self._tables: + element.accept(visitor) + visitor.leaveSection(self) + +class Table: + def __init__(self,params,cores): + self._params=params + self._cores=cores + self._rows=[] + + def addRow(self,row): + self._rows.append(row) + + @property + def columns(self): + return(self._params + self._cores) + + @property + def params(self): + return(self._params) + + @property + def cores(self): + return(self._cores) + + @property + def rows(self): + return(self._rows) + + def accept(self, visitor): + visitor.visitTable(self) + diff --git a/Testing/bench.txt b/Testing/bench.txt index 6271e774..d9101312 100755 --- a/Testing/bench.txt +++ b/Testing/bench.txt @@ -5,7 +5,7 @@ group Root { class = DSPBenchmarks folder = DSP - group Basic Maths Benchmarks { + group Basic Maths { class = BasicBenchmarks folder = BasicMaths @@ -747,7 +747,10 @@ group Root { } } - suite Barycenter { + group Barycenter { + class = Barycenter + + suite Barycenter { class = SupportBarF32 folder = SupportBarF32 @@ -770,6 +773,8 @@ group Root { Functions { Barycenter:test_barycenter_f32 } -> PARAM1_ID + + } } diff --git a/Testing/extractDb.py b/Testing/extractDb.py index a73975a5..dcce85da 100755 --- a/Testing/extractDb.py +++ b/Testing/extractDb.py @@ -3,385 +3,9 @@ import sqlite3 import re import pandas as pd import numpy as np +from TestScripts.doc.Structure import * +from TestScripts.doc.Format import * -remapNames={ -} - -def convertSectionName(s): - if s in remapNames: - return(remapNames[s]) - else: - return(s) - -class Document: - def __init__(self,runid,date): - self._runid = runid - self._date = date - self._sections = [] - - @property - def runid(self): - return(self._runid) - - @property - def date(self): - return(self._date) - - @property - def sections(self): - return(self._sections) - - def addSection(self,section): - self._sections.append(section) - - def accept(self, visitor): - visitor.visitDocument(self) - for element in self._sections: - element.accept(visitor) - visitor.leaveDocument(self) - -class Section: - def __init__(self,name): - self._name=convertSectionName(name) - self._subsections = [] - self._tables = [] - - def addSection(self,section): - self._subsections.append(section) - - def addTable(self,table): - self._tables.append(table) - - @property - def hasChildren(self): - return(len(self._subsections)>0) - - @property - def name(self): - return(self._name) - - def accept(self, visitor): - visitor.visitSection(self) - for element in self._subsections: - element.accept(visitor) - for element in self._tables: - element.accept(visitor) - visitor.leaveSection(self) - -class Table: - def __init__(self,params,cores): - self._params=params - self._cores=cores - self._rows=[] - - def addRow(self,row): - self._rows.append(row) - - @property - def columns(self): - return(self._params + self._cores) - - @property - def params(self): - return(self._params) - - @property - def cores(self): - return(self._cores) - - @property - def rows(self): - return(self._rows) - - def accept(self, visitor): - visitor.visitTable(self) - - - -class Markdown: - def __init__(self,output): - self._id=0 - self._output = output - - # Write columns in markdown format - def writeColumns(self,cols): - colStr = "".join(joinit(cols,"|")) - self._output.write("|") - self._output.write(colStr) - self._output.write("|\n") - sepStr="".join(joinit([":-:" for x in cols],"|")) - self._output.write("|") - self._output.write(sepStr) - self._output.write("|\n") - - # Write row in markdown format - def writeRow(self,row): - row=[str(x) for x in row] - rowStr = "".join(joinit(row,"|")) - self._output.write("|") - self._output.write(rowStr) - self._output.write("|\n") - - def visitTable(self,table): - self.writeColumns(table.columns) - for row in table.rows: - self.writeRow(row) - - def visitSection(self,section): - self._id = self._id + 1 - header = "".join(["#" for i in range(self._id)]) - output.write("%s %s\n" % (header,section.name)) - - def leaveSection(self,section): - self._id = self._id - 1 - - def visitDocument(self,document): - self._output.write("Run number %d on %s\n" % (document.runid, str(document.date))) - - def leaveDocument(self,document): - pass - -styleSheet=""" - -""" - -script="""""" - - -class HTMLToc: - def __init__(self,output): - self._id=0 - self._sectionID = 0 - self._output = output - - - - def visitTable(self,table): - pass - - - def visitSection(self,section): - self._id = self._id + 1 - self._sectionID = self._sectionID + 1 - if section.hasChildren: - self._output.write("
  • %s\n" % (self._sectionID,section.name)) - self._output.write("
  • \n") - - self._id = self._id - 1 - - def visitDocument(self,document): - self._output.write("

    Table of content

    %s\n" % script) - - -class HTML: - def __init__(self,output,regMode): - self._id=0 - self._sectionID = 0 - self._output = output - self._regMode = regMode - - - - def visitTable(self,table): - output.write("\n") - output.write("\n") - output.write("\n") - for col in table.columns: - output.write("\n") - output.write("\n") - output.write("\n") - for row in table.rows: - output.write("\n") - for elem in row: - output.write("\n") - output.write("\n") - output.write("
    ") - output.write(str(col)) - output.write("
    ") - output.write(str(elem)) - output.write("
    \n") - - - def visitSection(self,section): - self._id = self._id + 1 - self._sectionID = self._sectionID + 1 - output.write("%s\n" % (self._id,self._sectionID,section.name,self._id)) - - def leaveSection(self,section): - self._id = self._id - 1 - - def visitDocument(self,document): - self._output.write(""" - - - -Benchmarks%s\n""" % styleSheet) - if self._regMode: - 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))) - - def leaveDocument(self,document): - document.accept(HTMLToc(self._output)) - - self._output.write("\n") @@ -610,8 +234,12 @@ def regressionTableFor(name,section,ref,toSort,indexCols,field): row=[row[0]] + row[1:] else: row=list(row[0]) + row[1:] + if field=="MAXREGCOEF": + row=[("%.3f" % x) for x in row] dataTable.addRow(row) else: + if field=="MAXREGCOEF": + dataForFunc=[("%.3f" % x) for x in dataForFunc] dataTable.addRow(dataForFunc) def formatTableByCore(typeSection,testNames,cols,vals): @@ -683,10 +311,10 @@ def formatTableByCore(typeSection,testNames,cols,vals): dataTable.addRow(dataForFunc) # Add a report for each table -def addReportFor(document,benchName): +def addReportFor(document,runid,benchName): nbElems = getNbElemsInBenchCmd(benchName) if nbElems > 0: - categoryName = getCategoryName(benchName,document.runid) + categoryName = getCategoryName(benchName,runid) benchSection = Section(categoryName) document.addSection(benchSection) print("Process %s\n" % benchName) @@ -715,13 +343,52 @@ def addReportFor(document,benchName): +toc=[Hierarchy("BasicMathsBenchmarks"), +Hierarchy("ComplexMathsBenchmarks"), +Hierarchy("FastMath"), +Hierarchy("Filters", + [Hierarchy("FIR"), + Hierarchy("BIQUAD"), + Hierarchy("DECIM"), + Hierarchy("MISC")]), + +Hierarchy("Support Functions", + [Hierarchy("Support"), + Hierarchy("SupportBar")]), + +Hierarchy("Matrix Operations" , + [Hierarchy("Binary"), + Hierarchy("Unary")]), +Hierarchy("Transform"), + +] + +processed=[] + +def createDoc(document,sections,benchtables): + global processed + for s in sections: + if s.name in benchtables: + addReportFor(document,runid,s.name) + processed.append(s.name) + else: + section=Section(s.name) + document.addSection(section) + createDoc(section,s.sections,benchtables) try: benchtables=getBenchTables() theDate = getrunIDDate(runid) document = Document(runid,theDate) - for bench in benchtables: - addReportFor(document,bench) + createDoc(document,toc,benchtables) + misc=Section("Miscellaneous") + document.addSection(misc) + remaining=diff(benchtables,processed) + for bench in remaining: + addReportFor(misc,runid,bench) + + #for bench in benchtables: + # addReportFor(document,bench) with open(args.o,"w") as output: if args.t=="md": document.accept(Markdown(output))