Ejemplo n.º 1
0
  data["exectime"] = execTime
  json.dump(data, open(j,"w"))

def expectedExec(c):
  (model,lib,libName,name,data) = c
  if "expectedExec" in data:
    return data["expectedExec"]
  cursor.execute("SELECT exectime FROM [%s] WHERE libname = ? AND model = ? ORDER BY date DESC LIMIT 1" % branch, (libName,model))
  v = cursor.fetchone()
  data["expectedExec"] = (v or (0.0,))[0]
  return data["expectedExec"]

start=monotonic()
tests=sorted(tests, key=lambda c: expectedExec(c), reverse=True)
stop=monotonic()
print("Querying expected execution time: %s" % friendlyStr(stop-start))
sys.stdout.flush()

# Cleanup old runs
try:
  if clean:
    rmtree("./files")
    print("Cleaned files directory")
except OSError:
  pass
try:
  os.mkdir("files")
except OSError:
  pass
print("Created files directory")
sys.stdout.flush()
      color = None
      if phase2 > phase1:
        color = "better"
        numImproved += 1
      if phase2 < phase1:
        color = "warning"
        numRegression += 1
      if color is not None:
        msg = "%s &rarr; %s" % (shared.finalphaseName(phase1),shared.finalphaseName(phase2))
      elif min(phase1,phase2) >= timeMinPhase:
        msgs = []
        for (phase,times) in [(1,frontend),(2,backend),(3,simcode),(4,templates),(5,compile),(6,simulate)]:
          (t1,t2) = [float(d) for d in times.split(",")]
          if t2 > timeRel*t1 and t2 > timeAbs:
            color = "warning"
            msgs.append("%s performance %s &rarr; %s" % (shared.finalphaseName(phase),friendlyStr(t1),friendlyStr(t2)))
          elif t1 > timeRel*t2 and t1 > timeAbs:
            if color is None:
              color = "better"
            msgs.append("%s performance %s &rarr; %s" % (shared.finalphaseName(phase),friendlyStr(t1),friendlyStr(t2)))
        if color is None:
          raise Exception("Unknown regression/improvement...")
        if color == "better":
          numPerformanceImproved += 1
        else:
          numPerformanceRegression += 1
        msg = " ".join(msgs)
      regstrs.append('<tr><td>%s</td><td>%s</td><td class="%s">%s</td></tr>' % (libraryLink(branch, libname),modelLink(libname, model, "err"),color,msg))
    tpl = tpl.replace("#NUMIMPROVE#",str(numImproved)).replace("#NUMREGRESSION#",str(numRegression)).replace("#NUMPERFIMPROVE#",str(numPerformanceImproved)).replace("#NUMPERFREGRESSION#",str(numPerformanceRegression)).replace("#MODELCHANGES#", "\n".join(regstrs))
    tpl = tpl.replace("#BRANCH#",branch).replace("#DATE1#",dateStr(d1)).replace("#DATE2#",dateStr(d2))
Ejemplo n.º 3
0
        diff_text += "<p>Debug:<br />\n" + "<br />\n".join(models[branch][i]) + "</p>"
      entries += '<td%s><a%s>%s%s</a></td>' % (' class="warning"' if old_vs and old_vs[i]>vs[i] else (' class="better"' if old_vs and old_vs[i]<vs[i] else ""),' class="dot"' if diff_text else "",vs[i],('<span class="tooltip">%s</span>' % diff_text) if diff_text else "")
    entries += "</tr>"
    nsimulate[branch] += vs[6]
    if old_vs:
      old_vs = [max(vs[i], old_vs[i]) for i in range(0, len(vs))]
    else:
      old_vs = vs
  entries += "</table>\n"
  entries += "<table>\n"
  entries += entryhead
  for branch in branches:
    vs = [cursor.execute("SELECT COUNT(*) FROM [%s] WHERE date=? AND finalphase>=? AND libname=?" % (branch), (dates[branch][lib],i,lib)).fetchone()[0] for i in range(0,8)]
    sums = [cursor.execute("SELECT SUM(%s) FROM [%s] WHERE date=? AND libname=?" % (fields[i],branch), (dates[branch][lib],lib)).fetchone()[0] or 0 for i in range(0,9)]
    entries += '<tr><td><a href="%s/%s/%s.html">%s</a></td>' % (branch,lib,lib,branch)
    entries += ("<td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n" % (friendlyStr(sums[0]),friendlyStr(sums[1]),friendlyStr(sums[2]),friendlyStr(sums[3]),friendlyStr(sums[4]),friendlyStr(sums[5]),friendlyStr(sums[6]),friendlyStr(sums[7]),friendlyStr(sums[8])))
    exectime[branch] += sums[0]
  entries += "</table>\n"
  # print(sorted(list(libs[lib])))

nummodels = sum(len(l) for l in libs.values())
branches_lines = [("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td%s>%d</td><td>%d</td></tr>\n" % (cgi.escape(branch), cgi.escape(
  (cursor.execute("SELECT omcversion FROM [omcversion] WHERE date=? AND branch=?", (max(dates[branch][lib] for lib in libnames),branch)).fetchone() or ["unknown"])[0]
  ), cgi.escape(dates_str[branch]), friendlyStr(exectime[branch]),
  " class=\"warning\"" if nummodels!=nmodels[branch] else "",
  nsimulate[branch],
  nmodels[branch]
)) for branch in branches]
template = open("overview.html.tpl").read()
replacements = (
  (u"#title#", "OpenModelica Library Testing Overview"),
def expectedExec(c):
    (model, lib, libName, name, data) = c
    if "expectedExec" in data:
        return data["expectedExec"]
    cursor.execute(
        "SELECT exectime FROM [%s] WHERE libname = ? AND model = ? ORDER BY date DESC LIMIT 1"
        % branch, (libName, model))
    v = cursor.fetchone()
    data["expectedExec"] = (v or (0.0, ))[0]
    return data["expectedExec"]


start = monotonic()
tests = sorted(tests, key=lambda c: expectedExec(c), reverse=True)
stop = monotonic()
print("Querying expected execution time: %s" % friendlyStr(stop - start))
sys.stdout.flush()

# Cleanup old runs
try:
    if clean:
        rmtree("./files")
        print("Cleaned files directory")
except OSError:
    pass
try:
    os.mkdir("files")
except OSError:
    pass
print("Created files directory")
sys.stdout.flush()
                "SELECT COUNT(*) FROM [%s] WHERE date=? AND finalphase>=? AND libname=?"
                % (branch), (dates[branch][lib], i, lib)).fetchone()[0]
            for i in range(0, 8)
        ]
        sums = [
            cursor.execute(
                "SELECT SUM(%s) FROM [%s] WHERE date=? AND libname=?" %
                (fields[i], branch), (dates[branch][lib], lib)).fetchone()[0]
            or 0 for i in range(0, 9)
        ]
        entries += '<tr><td><a href="%s/%s/%s.html">%s</a></td>' % (
            branch, lib, lib, branch)
        entries += (
            "<td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n"
            %
            (friendlyStr(sums[0]), friendlyStr(sums[1]), friendlyStr(sums[2]),
             friendlyStr(sums[3]), friendlyStr(sums[4]), friendlyStr(sums[5]),
             friendlyStr(sums[6]), friendlyStr(sums[7]), friendlyStr(sums[8])))
        exectime[branch] += sums[0]
    entries += "</table>\n"
    # print(sorted(list(libs[lib])))

nummodels = sum(len(l) for l in libs.values())
branches_lines = [(
    "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td%s>%d</td><td>%d</td></tr>\n"
    % (html.escape(branch),
       html.escape((cursor.execute(
           "SELECT omcversion FROM [omcversion] WHERE date=? AND branch=?",
           (max(dates[branch][lib]
                for lib in libnames), branch)).fetchone() or ["unknown"])[0]),
       html.escape(dates_str[branch]), friendlyStr(exectime[branch]),
     color = "warning"
     numRegression += 1
 if color is not None:
     msg = "%s &rarr; %s" % (shared.finalphaseName(phase1),
                             shared.finalphaseName(phase2))
 elif min(phase1, phase2) >= timeMinPhase:
     msgs = []
     for (phase, times) in [(1, frontend), (2, backend),
                            (3, simcode), (4, templates),
                            (5, compile), (6, simulate)]:
         (t1, t2) = [float(d) for d in times.split(",")]
         if t2 > timeRel * t1 and t2 > timeAbs:
             color = "warningPerformance"
             msgs.append("%s performance %s &rarr; %s" %
                         (shared.finalphaseName(phase),
                          friendlyStr(t1), friendlyStr(t2)))
         elif t1 > timeRel * t2 and t1 > timeAbs:
             if color is None:
                 color = "betterPerformance"
             msgs.append("%s performance %s &rarr; %s" %
                         (shared.finalphaseName(phase),
                          friendlyStr(t1), friendlyStr(t2)))
     if color is None:
         raise Exception("Unknown regression/improvement...")
     if color == "betterPerformance":
         numPerformanceImproved += 1
     else:
         numPerformanceRegression += 1
     msg = " ".join(msgs)
 else:
     msg = ""  # Happens if we try to generate a report without previous results