]> rtime.felk.cvut.cz Git - can-benchmark.git/blobdiff - continuous/www/wvperf2html.py
Update graph generator to actually work
[can-benchmark.git] / continuous / www / wvperf2html.py
index 0fed0edaf3fc0415d70f2c0ff064f85f4f62ecce..3c3607b315f1b4623955bf32ab0a8dfcabb301f2 100755 (executable)
@@ -17,22 +17,21 @@ import os
 import os.path
 import string
 import time
+from datetime import timedelta,datetime
 import numpy as np
 import json
 
 
 re_prefix = "\([0-9]+\) (?:#   )?"
-re_date = re.compile('^! Date: (.*) ok')
+re_date = re.compile('^! Date: (.*?) ok')
 re_testing = re.compile('^('+re_prefix+')?\s*Testing "(.*)" in (.*):\s*$')
-re_commit = re.compile('.*(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}).*, commit: (.*)')
-re_commithash = re.compile('([0-9a-f]{7})(-dirty)? \(')
+re_repo = re.compile('^! Repo (?P<url>[^ ]*) (?P<desc>[^ ]*) (?P<hash>[0-9a-f]*) ok')
 re_assertion = re.compile('^('+re_prefix+')?!\s*(.*?)\s+(\S+)\s*$')
 re_perf =  re.compile('^('+re_prefix+')?!\s*(.*?)\s+PERF:\s*(.*?)\s+(\S+)\s*$')
 re_perfaxis = re.compile('axis="([^"]+)"')
 
 def dateConv(date):
-    d = time.gmtime(time.mktime(date))
-    return int(time.mktime(d))*1000
+    return int(time.mktime(date.timetuple()))*1000
 
 
 class Axis:
@@ -93,6 +92,8 @@ class Graph:
             return self.rows[rownum]
 
     def addValue(self, date, col, val, units):
+        if col == "gw_latency" and val == 0:
+            val = None
         row = self[date]
         row[col] = val
         if col not in self.columns:
@@ -146,7 +147,7 @@ class Graph:
     def options_json(self):
         options = {
             'rangeSelector': {
-                'selected': 2 # 6m
+                'selected': 5 # All
             },
             'title': {
                 'text': self.title
@@ -175,6 +176,9 @@ class Graph:
                     },
                 }
             },
+            'xAxis': {
+                'ordinal' : False,
+                },
             'yAxis': [{
                     'lineWidth': 1,
                     'labels': { 'align': 'right',
@@ -189,7 +193,7 @@ class Graph:
         return json.dumps(options, indent=True).replace('"FUN(', '').replace(')END"', '')
 
     def getData(self):
-        data = [[[row.getDate(), row[col.name]] for row in self.rows] for col in self.columns_ordered]
+        data = [[[row.getDate(), row[col.name]] for row in sorted(self.rows, cmp, lambda r: r.date)] for col in self.columns_ordered]
         return json.dumps(data).replace('], [', '],\n[')
 
 
@@ -200,33 +204,35 @@ graphs = Graphs()
 date2commit = {}
 commit2msg = {}
 
-date = time.localtime(time.time())
+date = datetime.now()
 
 for line in sys.stdin:
     line = line.rstrip()
 
     match = re_date.match(line)
     if (match):
-        date = time.strptime(match.group(1), "%Y-%m-%d %H:%M:%S")
+        dstr = match.group(1)
+        words = dstr.split()
+
+        date = datetime.strptime(string.join(words[0:2]), "%Y-%m-%d %H:%M:%S")
+        if (len(words) > 2):
+            zone_hours = int(words[2])/100
+            date -= timedelta(hours = zone_hours)
         continue
 
+    match = re_repo.match(line)
+    if (match):
+        url = match.group('url')
+        desc = match.group('desc')
+        hash = match.group('hash')
+
+        date2commit[date] = hash
+        commit2msg[hash] = desc
+
     match = re_testing.match(line)
     if match:
         what = match.group(2)
         where = match.group(3)
-
-        match = re_commit.match(what)
-        if match:
-            date = time.strptime(match.group(1), "%Y-%m-%d %H:%M:%S")
-            commit = match.group(2)
-            match = re_commithash.search(commit);
-            if match:
-                commithash = match.group(1)
-            else:
-                commithash = None
-            date2commit[dateConv(date)] = commithash
-            commit2msg[commithash] = commit
-
         (basename, ext) = os.path.splitext(os.path.basename(where))
 
         if what != "all": title = what
@@ -294,9 +300,9 @@ print("""
         }
       }
       if (prevpoint && date2commit[prevpoint.x] != date2commit[event.point.x])
-        window.location = "https://github.com/TUD-OS/NUL/compare/"+date2commit[prevpoint.x]+'...'+date2commit[event.point.x];
+          window.location = "https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/log/?qt=range&q="+date2commit[prevpoint.x]+'..'+date2commit[event.point.x];
       else
-        window.location = "https://github.com/TUD-OS/NUL/commit/"+date2commit[event.point.x];
+          window.location = "https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/log/?id="+date2commit[event.point.x];
     }""")
 
 def make_int_keys(json):
@@ -306,7 +312,7 @@ def make_int_keys(json):
         s += match.expand('\\1\\2')
     return s
 
-print("var date2commit = {%s};" % ",\n".join(["%d: '%s'" % (k, date2commit[k]) for k in sorted(date2commit.keys())]))
+print("var date2commit = {%s};" % ",\n".join(["%d: '%s'" % (dateConv(k), date2commit[k]) for k in sorted(date2commit.keys())]))
 print("var commit2msg = %s;" % json.dumps(commit2msg, indent=True))
 # for d in sorted(date2commit.keys()):
 #     v = commits[d];
@@ -317,18 +323,18 @@ print("""
     </head>
 
     <body>
-       <h1>NUL Performance Plots</h1>
+       <h1>Linux CAN subsystem performance plots</h1>
     <p>The graphs below show performance numbers from various
-    benchmarks that run nightly on NUL repository.</p>
+    CAN bus related benchmarks run on different Linux kernel versions.</p>
     <p>Table of content:</p>
         <ul>
 """)
 for graph in graphs:
-    print("    <li><a href='#%s'>%s</a></li>" % (graph.title, graph.title))
+    print("    <li><a href='#%s'>%s</a></li>" % (graph.id, graph.title))
 print("    </ul>")
 for graph in graphs:
     print("""
-    <h2><a name='%(title)s'>%(title)s</a></h2>
+    <h2><a name='%(id)s'>%(title)s</a></h2>
        <div id="%(id)s" style="height: 400px"></div>
     <script>
 $.getJSON('%(dataname)s', function(data) {