1#!/usr/bin/python
2
3# http://test.kernel.org/perf/kernbench.elm3b6.png
4
5import cgi, cgitb, os, sys, re, subprocess
6cgitb.enable()
7Popen = subprocess.Popen
8
9import common
10from autotest_lib.tko import db, display, frontend, plotgraph
11from autotest_lib.client.common_lib import kernel_versions
12
13db = db.db()
14
15def main():
16    form = cgi.FieldStorage()
17    machine_idx = form["machine"].value
18    benchmark = form["benchmark"].value
19    key = form["key"].value
20
21    machine = frontend.machine.select(db, {'machine_idx' : machine_idx})[0]
22
23    data = {}
24    where = { 'subdir' : benchmark, 'machine_idx' : machine.idx }
25    for test in frontend.test.select(db, where):
26        iterations = test.iterations()
27        if iterations.has_key(key):
28            data[test.kernel().printable] = iterations[key]
29
30    # for kernel in sort_kernels(data.keys()):
31    #    print "%s %s" % (kernel, str(data[kernel]))
32    title = "%s on %s" % (benchmark, machine.hostname)
33    graph = plotgraph.gnuplot(title, 'Kernel', key, xsort = sort_kernels)
34    graph.add_dataset('all kernels', data)
35    graph.plot(cgi_header = True)
36
37
38def sort_kernels(kernels):
39    return sorted(kernels, key = kernel_versions.version_encode)
40
41main()
42