]> rtime.felk.cvut.cz Git - can-benchmark.git/blobdiff - tests/genhtml.py
Gzip ramdisk - booting is faster
[can-benchmark.git] / tests / genhtml.py
index 9e3263ef1333a95d166e530506a3544adf3466da..9367a1e4e6ed33e74a1170c9c39a936ee349f0c5 100755 (executable)
@@ -3,6 +3,7 @@
 import os;
 import dircache;
 import sys;
+import urllib
 
 os.chdir(sys.argv[1])
 
@@ -11,46 +12,62 @@ class Axis:
         self.type = atype
         self.values = dircache.listdir('by-%s'%atype)
 
-    def __str__(self):
-        if self.type == "kern": return "kernel"
-        elif self.type == "clck": return "CPU clock"
-        elif self.type == "test": return "test"
-        else: raise Exception, "Unknown type"
-
     def __iter__(self):
         return iter(self.values)
 
     def __getitem__(self, key):
         return self.values[key]
 
-    def getLabel(self, v):
-        if self.type == "clck": return v+" MHz"
-        elif self.type == "test": return "<a href='%s.sh.html'>%s</a>"%(v, v)
-        else: return v
-
-
     def labels(self):
         for v in self.values:
             yield self.getLabel(v)
+
+class AxisKern(Axis):
+    def __init__(self):
+        Axis.__init__(self, 'kern')
+    def getLabel(self, v):
+        i=v.find(":")
+        if i>0: kver=v[:i]
+        else: kver=v
+        return v+"<br><a href='config-%s'>config</a>"%(urllib.quote(kver))
+    def versions(self):
+        for v in self.values:
+            i=v.find(":")
+            if i>0: kver=v[:i]
+            else: kver=v
+            yield kver
         
-kernels = Axis('kern')
-clocks = Axis('clck')
-tests = Axis('test')
+    
+
+class AxisClck(Axis):
+    def __init__(self):
+        Axis.__init__(self, 'clck')
+    def getLabel(self, v):
+        return v+" MHz"
+
+class AxisTest(Axis):
+    def __init__(self):
+        Axis.__init__(self, 'test')
+    def getLabel(self, v):
+        return v+"<br><a href='%s.sh.html'>source</a>"%(urllib.quote(v))
+    
+kernels = AxisKern()
+clocks =  AxisClck()
+tests =   AxisTest()
 
 class PageSet:
-    def __init__(self, values, x, y):
+    def __init__(self, pageclass, values, x, y):
+        self.pageclass = pageclass
         self.values = values
         self.x = x
         self.y = y
 
     def getPages(self):
         for v in self.values:
-            yield Page(self.values.type, str(self.values), v, self.x, self.y)
+            yield self.pageclass(v, self.x, self.y)
 
 class Page:
-    def __init__(self, prefix, name, value, xvals, yvals):
-        self.prefix = prefix
-        self.name = name
+    def __init__(self, value, xvals, yvals):
         self.value = value
         self.xvals = xvals
         self.yvals = yvals
@@ -63,22 +80,26 @@ class Page:
 <style>
 img { border: 0; }
 table { border-collapse: collapse; }
-td { border: 1px solid lightgray; padding: 4px;}
+th, td { border: 1px solid lightgray; padding: 4px;}
 </style>
 </head>
 <body>
 <h1>CAN driver benchmark for %s %s</h1>"""  % (self.name, self.value, self.name, self.value)
         for ps in pagesets:
-            print >>html, "View by %s: " % str(ps.values)
+            print >>html, "View only %s: " % str(ps.pageclass.name)
             for v in ps.values:
-                print >>html, "<a href='%s-%s.html'>%s</a> | "%(ps.values.type, v, v)
+                print >>html, "<a href='%s-%s.html'>%s</a> | "%(ps.values.type, urllib.quote(v), v)
             print >>html, "<br>"
+        try:
+            print >>html, self.getPreambule()
+        except Exception:
+            pass
         print >>html, "<table><thead><tr><td> </td>"
         for x in self.xvals.labels():
-            print >>html, "<td>%s</td>" % x
+            print >>html, "<th>%s</th>" % x
         print >>html, "</tr></thead>"
         for y in self.yvals:
-            print >>html, "<tr><td>%s</td>" % self.yvals.getLabel(y)
+            print >>html, "<tr><th>%s</th>" % self.yvals.getLabel(y)
 
             for x in self.xvals:
                 print >>html, "<td>"
@@ -86,7 +107,7 @@ td { border: 1px solid lightgray; padding: 4px;}
                 dthumb = d+"thumb"
                 try:
                     for img in dircache.listdir(dthumb):
-                        print >>html, "<a href='%s/%s'><img src='%s/thumb/%s'></a>" % (d, img, d, img)
+                        print >>html, "<a href='%s/%s'><img src='%s/thumb/%s'></a>" % (urllib.quote(d), img, urllib.quote(d), img)
                 except OSError:
                     print "warning: no images in %s?"%dthumb
                 print >>html, "</td>"
@@ -96,10 +117,36 @@ td { border: 1px solid lightgray; padding: 4px;}
 </body>
 """
 
-
-pagesets = [ PageSet(kernels, clocks, tests),
-             PageSet(tests, clocks, kernels),
-             PageSet(clocks, kernels, tests)]
+class PageKern(Page):
+    prefix = 'kern'
+    name = 'kernel'
+    def __init__(self, value, xvals, yvals):
+        Page.__init__(self, value, xvals, yvals)
+    def getPreambule(self):
+        i=self.value.find(":")
+        if i>0: kver=self.value[:i]
+        else: kver=self.value
+        return "<p><a href='config-%s'>Kernel config</a></p>"%kver
+
+class PageClck(Page):
+    prefix = 'clck'
+    name = 'CPU clock'
+    def __init__(self, value, xvals, yvals):
+        Page.__init__(self, value, xvals, yvals)
+
+class PageTest(Page):
+    prefix = 'test'
+    name = 'test'
+    def __init__(self, value, xvals, yvals):
+        Page.__init__(self, value, xvals, yvals)
+    def getPreambule(self):
+        return "<p><a href='%s.sh.html'>Test source</a></p>"%(urllib.quote(self.value))
+
+
+
+pagesets = [ PageSet(PageKern, kernels, clocks, tests),
+             PageSet(PageTest, tests, clocks, kernels),
+             PageSet(PageClck, clocks, kernels, tests)]
 
 for ps in pagesets:
     for p in ps.getPages():
@@ -109,9 +156,10 @@ try:
     os.remove("index.html")
 except OSError: pass
 
-os.symlink("%s-%s.html"%(kernels.type, kernels[0]), "index.html")
+os.symlink("%s-%s.html"%(clocks.type, clocks[0]), "index.html")
 
 os.system("source-highlight -d --output-dir=. ../*.sh")
     
 
-
+for v in kernels.versions():
+    os.system("cp /boot/config-%s ."%v)