CMSIS-DSP: Reworked mechanism for naming of tests.
diff --git a/CMSIS/DSP/Testing/extractDb.py b/CMSIS/DSP/Testing/extractDb.py
index f9c91a4..a73975a 100755
--- a/CMSIS/DSP/Testing/extractDb.py
+++ b/CMSIS/DSP/Testing/extractDb.py
@@ -5,18 +5,6 @@
 import numpy as np
 
 remapNames={
-  "BasicMathsBenchmarks": "Basic Maths",
-  "ComplexMathsBenchmarks": "Complex Maths",
-  "FIR": "FIR",
-  "MISC": "Convolutions / Correlations",
-  "DECIM": "Decimations / Interpolations",
-  "BIQUAD": "BiQuad",
-  "FastMath": "Fast Maths",
-  "SupportBar": "Barycenter",
-  "Support": "Support Functions",
-  "Unary": "Matrix Unary Operations",
-  "Binary": "Matrix Binary Operations",
-  "Transform": "Vector Transform"
 }
 
 def convertSectionName(s):
@@ -160,10 +148,11 @@
   position: fixed;
   left: 0;
   top: 0;
-  width: 250px;
+  width: 280px;
   height: 100%;
   overflow:auto;
   margin-top:5px;
+  margin-bottom:10px;
 }
 
 html {
@@ -180,7 +169,7 @@
 body {
   margin: auto;
   margin-top:0px;
-  margin-left:250px;
+  margin-left:280px;
 
 }
 
@@ -341,10 +330,11 @@
 
 
 class HTML:
-  def __init__(self,output):
+  def __init__(self,output,regMode):
     self._id=0
     self._sectionID = 0
     self._output = output
+    self._regMode = regMode
 
   
 
@@ -382,7 +372,10 @@
 <head>
 <meta charset='UTF-8'><meta name='viewport' content='width=device-width initial-scale=1'>
 <title>Benchmarks</title>%s</head><body>\n""" % styleSheet)
-      self._output.write("<h1>ECPS Benchmark Summary</h1>\n")
+      if self._regMode:
+         self._output.write("<h1>ECPS Benchmark Regressions</h1>\n")
+      else:
+         self._output.write("<h1>ECPS Benchmark Summary</h1>\n")
       self._output.write("<p>Run number %d on %s</p>\n" % (document.runid, str(document.date)))
 
   def leaveDocument(self,document):
@@ -420,7 +413,7 @@
 parser.add_argument('-t', nargs='?',type = str, default="md", help="md,html")
 
 # For runid or runid range
-parser.add_argument('others', nargs=argparse.REMAINDER)
+parser.add_argument('others', nargs=argparse.REMAINDER,help="Run ID")
 
 args = parser.parse_args()
 
@@ -433,14 +426,14 @@
 
 # We extract data only from data tables
 # Those tables below are used for descriptions
-REMOVETABLES=['RUN','CORE', 'PLATFORM', 'COMPILERKIND', 'COMPILER', 'TYPE', 'CATEGORY', 'CONFIG']
+REMOVETABLES=['TESTNAME','TESTDATE','RUN','CORE', 'PLATFORM', 'COMPILERKIND', 'COMPILER', 'TYPE', 'CATEGORY', 'CONFIG']
 
 # This is assuming the database is generated by the regression script
 # So platform is the same for all benchmarks.
 # Category and type is coming from the test name in the yaml
 # So no need to add this information here
 # Name is removed here because it is added at the beginning
-REMOVECOLUMNS=['runid','NAME','type','platform','category','coredef','OPTIMIZED','HARDFP','FASTMATH','NEON','HELIUM','UNROLL','ROUNDING','DATE','compilerkindid','date','categoryid', 'ID', 'platformid', 'coreid', 'compilerid', 'typeid']
+REMOVECOLUMNS=['runid','name','type','platform','category','coredef','OPTIMIZED','HARDFP','FASTMATH','NEON','HELIUM','UNROLL','ROUNDING','DATE','compilerkindid','date','categoryid', 'ID', 'platformid', 'coreid', 'compilerid', 'typeid']
 
 # Get existing benchmark tables
 def getBenchTables():
@@ -458,14 +451,19 @@
     return(result)
 
 # Get compilers from specific type and table
-versioncompiler="""select distinct compiler,version from %s 
-  INNER JOIN COMPILER USING(compilerid)
-  INNER JOIN COMPILERKIND USING(compilerkindid) WHERE typeid=?"""
+allCompilers="""select distinct compilerid from %s WHERE typeid=?"""
+
+compilerDesc="""select compiler,version from COMPILER 
+  INNER JOIN COMPILERKIND USING(compilerkindid) WHERE compilerid=?"""
 
 # Get existing compiler in a table for a specific type
 # (In case report is structured by types)
 def getExistingCompiler(benchTable,typeid):
-    r=c.execute(versioncompiler % benchTable,(typeid,)).fetchall()
+    r=c.execute(allCompilers % benchTable,(typeid,)).fetchall()
+    return([x[0] for x in r])
+
+def getCompilerDesc(compilerid):
+    r=c.execute(compilerDesc,(compilerid,)).fetchone()
     return(r)
 
 # Get type name from type id
@@ -488,17 +486,19 @@
   INNER JOIN COMPILER USING(compilerid)
   INNER JOIN COMPILERKIND USING(compilerkindid)
   INNER JOIN TYPE USING(typeid)
-  WHERE compiler=? AND VERSION=? AND typeid = ? AND runid = ?
+  INNER JOIN TESTNAME USING(testnameid)
+  WHERE compilerid=? AND typeid = ? AND runid = ?
   """
 
 
 # Command to get test names for specific compiler 
 # and type
-benchNames="""select distinct NAME from %s
+benchNames="""select distinct name from %s
   INNER JOIN COMPILER USING(compilerid)
   INNER JOIN COMPILERKIND USING(compilerkindid)
   INNER JOIN TYPE USING(typeid)
-  WHERE compiler=? AND VERSION=? AND typeid = ? AND runid = ?
+  INNER JOIN TESTNAME USING(testnameid)
+  WHERE compilerid=? AND typeid = ? AND runid = ?
   """
 
 # Command to get columns for specific table
@@ -508,6 +508,7 @@
   INNER JOIN CORE USING(coreid)
   INNER JOIN COMPILER USING(compilerid)
   INNER JOIN COMPILERKIND USING(compilerkindid)
+  INNER JOIN TESTNAME USING(testnameid)
   INNER JOIN TYPE USING(typeid)
   """
 
@@ -529,45 +530,36 @@
 # Get test names
 # for specific typeid and compiler (for the data)
 def getTestNames(benchTable,comp,typeid):
-    vals=(comp[0],comp[1],typeid,runid)
+    vals=(comp,typeid,runid)
     result=c.execute(benchNames % benchTable,vals).fetchall()
     return([x[0] for x in list(result)])
 
 # Command to get data for specific compiler 
 # and type
 nbElemsInBenchAndTypeAndCompilerCmd="""select count(*) from %s
-  INNER JOIN CATEGORY USING(categoryid)
-  INNER JOIN PLATFORM USING(platformid)
-  INNER JOIN CORE USING(coreid)
-  INNER JOIN COMPILER USING(compilerid)
-  INNER JOIN COMPILERKIND USING(compilerkindid)
-  INNER JOIN TYPE USING(typeid)
-  WHERE compiler=? AND VERSION=? AND typeid = ? AND runid = ?
+  WHERE compilerid=? AND typeid = ? AND runid = ?
   """
 
 nbElemsInBenchAndTypeCmd="""select count(*) from %s
-  INNER JOIN CATEGORY USING(categoryid)
-  INNER JOIN PLATFORM USING(platformid)
-  INNER JOIN CORE USING(coreid)
-  INNER JOIN COMPILER USING(compilerid)
-  INNER JOIN COMPILERKIND USING(compilerkindid)
-  INNER JOIN TYPE USING(typeid)
   WHERE typeid = ? AND runid = ?
   """
 
 nbElemsInBenchCmd="""select count(*) from %s
-  INNER JOIN CATEGORY USING(categoryid)
-  INNER JOIN PLATFORM USING(platformid)
-  INNER JOIN CORE USING(coreid)
-  INNER JOIN COMPILER USING(compilerid)
-  INNER JOIN COMPILERKIND USING(compilerkindid)
-  INNER JOIN TYPE USING(typeid)
   WHERE runid = ?
   """
 
+categoryName="""select distinct category from %s
+  INNER JOIN CATEGORY USING(categoryid)
+  WHERE runid = ?
+  """
+
+def getCategoryName(benchTable,runid):
+  result=c.execute(categoryName % benchTable,(runid,)).fetchone()
+  return(result[0])
+
 # Get nb elems in a table
 def getNbElemsInBenchAndTypeAndCompilerCmd(benchTable,comp,typeid):
-    vals=(comp[0],comp[1],typeid,runid)
+    vals=(comp,typeid,runid)
     result=c.execute(nbElemsInBenchAndTypeAndCompilerCmd % benchTable,vals).fetchone()
     return(result[0])
 
@@ -587,9 +579,9 @@
     cursor=c.cursor()
     result=cursor.execute(benchCmdColumns % (benchTable))
     cols= [member[0] for member in cursor.description]
-    keepCols = ['NAME'] + [c for c in diff(cols , REMOVECOLUMNS) if isNotIDColumn(c)]
+    keepCols = ['name'] + [c for c in diff(cols , REMOVECOLUMNS) if isNotIDColumn(c)]
     keepColsStr = "".join(joinit(keepCols,","))
-    vals=(comp[0],comp[1],typeid,runid)
+    vals=(comp,typeid,runid)
     result=cursor.execute(benchCmd % (keepColsStr,benchTable),vals)
     vals =np.array([list(x) for x in list(result)])
     return(keepCols,vals)
@@ -605,7 +597,7 @@
     data=data.sort_values(toSort)
        
     cores = [c[1] for c in list(data.columns)]
-    columns = diff(indexCols,['NAME'])
+    columns = diff(indexCols,['name'])
 
     dataTable=Table(columns,cores)
     section.addTable(dataTable)
@@ -625,7 +617,7 @@
 def formatTableByCore(typeSection,testNames,cols,vals):
     if vals.size != 0:
        ref=pd.DataFrame(vals,columns=cols)
-       toSort=["NAME"]
+       toSort=["name"]
        
        for param in PARAMS:
           if param in ref.columns:
@@ -670,7 +662,7 @@
               data=data.sort_values(toSort)
        
               cores = [c[1] for c in list(data.columns)]
-              columns = diff(indexCols,['NAME'])
+              columns = diff(indexCols,['name'])
 
               testSection = Section(name)
               typeSection.addSection(testSection)
@@ -694,7 +686,8 @@
 def addReportFor(document,benchName):
     nbElems = getNbElemsInBenchCmd(benchName)
     if nbElems > 0:
-       benchSection = Section(benchName)
+       categoryName = getCategoryName(benchName,document.runid)
+       benchSection = Section(categoryName)
        document.addSection(benchSection)
        print("Process %s\n" % benchName)
        allTypes = getExistingTypes(benchName)
@@ -712,7 +705,8 @@
                   nbElems = getNbElemsInBenchAndTypeAndCompilerCmd(benchName,compiler,aTypeID)
                   # Print test results for table, type, compiler
                   if nbElems > 0:
-                     compilerSection = Section("%s (%s)" % compiler)
+                     compilerName,version=getCompilerDesc(compiler)
+                     compilerSection = Section("%s (%s)" % (compilerName,version))
                      typeSection.addSection(compilerSection)
                      cols,vals=getColNamesAndData(benchName,compiler,aTypeID)
                      names=getTestNames(benchName,compiler,aTypeID)
@@ -732,7 +726,7 @@
           if args.t=="md":
              document.accept(Markdown(output))
           if args.t=="html":
-             document.accept(HTML(output))
+             document.accept(HTML(output,args.r))
 
 finally:
      c.close()