]> rtime.felk.cvut.cz Git - can-benchmark.git/blobdiff - continuous/www/wvperf2html.py
Move highstock one level up
[can-benchmark.git] / continuous / www / wvperf2html.py
index 0fed0edaf3fc0415d70f2c0ff064f85f4f62ecce..38bd2ead2255de96af2aa796d2f8ecd279b9f232 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:
@@ -145,8 +146,11 @@ class Graph:
 
     def options_json(self):
         options = {
+            'chart': {
+                'borderWidth': 1,
+                },
             'rangeSelector': {
-                'selected': 2 # 6m
+                'selected': 5 # All
             },
             'title': {
                 'text': self.title
@@ -175,12 +179,16 @@ class Graph:
                     },
                 }
             },
+            'xAxis': {
+                'ordinal' : False,
+                },
             'yAxis': [{
                     'lineWidth': 1,
                     'labels': { 'align': 'right',
                         'x': -3 },
                     'title': { 'text': axis.getLabel() },
                     'minRange': axis.minrange,
+                    'tickPixelInterval': 40,
                     } for axis in self.axes_ordered],
             'series': [{ 'name': '%s [%s]' % (col.name, col.units),
                  'yAxis': col.axis.num }
@@ -189,7 +197,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 +208,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
@@ -268,17 +278,18 @@ for g in graphs:
     g.findRanges()
     g.fixupAxisNumbers()
 
+pagetitle="Linux CAN subsystem performance plots"
 print("""
 <!DOCTYPE HTML>
 <html>
   <head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-  <title>NUL Performance Plots</title>
+  <title>%(pagetitle)s</title>
 
   <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
   <script type="text/javascript">
     function tooltip_formatter() {
-      var s = '<b>'+ Highcharts.dateFormat('%a, %d %b %Y %H:%M:%S', this.x) +'</b><br/>';
+      var s = '<b>'+ Highcharts.dateFormat('%%a, %%d %%b %%Y %%H:%%M:%%S', this.x) +'</b><br/>';
       s += commit2msg[date2commit[this.x]];
       $.each(this.points, function(i, point) {
         s += '<br/><span style="color:'+ point.series.color+';">'+ point.series.name +'</span>: '+point.y;
@@ -294,10 +305,10 @@ 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];
+    }""" % locals())
 
 def make_int_keys(json):
     r = re.compile('"(\d+)"(.*)')
@@ -306,29 +317,29 @@ 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];
 #     print('\t%d: { msg: "%s", hash: "%s" },' % (1000*time.mktime(d), v[0].replace('"', '\\"'), str(v[1]).replace('"', '\\"')))
 print("""
        </script>
-       <script type="text/javascript" src="js/highstock.js"></script>
+       <script type="text/javascript" src="highstock.js"></script>
     </head>
 
     <body>
-       <h1>NUL Performance Plots</h1>
+       <h1>%(pagetitle)s</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>
-""")
+""" % locals())
 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) {
@@ -343,11 +354,8 @@ $.getJSON('%(dataname)s', function(data) {
        'dataname': graph.dataname,
        'options': graph.options_json()})
     print(graph.getData(), file=open(graph.dataname, 'w'))
+print("Generated on "+str(datetime.now()))
 print("""
     </body>
 </html>
 """)
-
-# Local Variables:
-# compile-command: "make perf"
-# End: