blob: 083abc400c53fc7f883878df9f35644c5de97dc5 [file] [log] [blame]
mbligh378e0ae2008-03-06 00:07:48 +00001#!/usr/bin/python
2print "Content-type: text/html\n"
3import cgi, cgitb, os, sys, re
4sys.stdout.flush()
5cgitb.enable()
6
jadmanski22ab0692008-05-01 22:22:51 +00007import common
8from autotest_lib.tko import db, display, frontend
mbligh378e0ae2008-03-06 00:07:48 +00009
10db = db.db()
11
12benchmark_key = {
mblighc3c8eab2009-01-21 18:50:57 +000013'kernbench' : ["elapsed"],
14'dbench' : ["throughput"],
15'tbench' : ["throughput"],
mbligh378e0ae2008-03-06 00:07:48 +000016}
17
18def main():
mbligh15110b72009-01-13 23:33:33 +000019 display.print_main_header()
20 ## it is table only; mouse hovering off
mblighc3c8eab2009-01-21 18:50:57 +000021 display.set_brief_mode()
mbligh378e0ae2008-03-06 00:07:48 +000022
mblighc3c8eab2009-01-21 18:50:57 +000023 ## getting available tests
showardeab66ce2009-12-23 00:03:56 +000024 rows = db.select('test', 'tko_tests', {}, distinct=True)
mblighc3c8eab2009-01-21 18:50:57 +000025 all_benchmarks = []
mbligh15110b72009-01-13 23:33:33 +000026 for row in rows:
27 benchmark = row[0]
28 testname = re.sub(r'\..*', '', benchmark)
mblighc3c8eab2009-01-21 18:50:57 +000029 all_benchmarks.append(benchmark)
30 all_benchmarks = display.sort_tests(all_benchmarks)
31
32 available_params = set()
33 for benchmark in all_benchmarks:
34 fields_tests = 'test_idx, count(status_word)'
35 where_tests = { 'subdir': benchmark, 'status_word' : 'GOOD' }
36 fields_params = 'attribute'
showardeab66ce2009-12-23 00:03:56 +000037 for (id, count) in db.select(fields_tests, 'tko_test_view',
mblighc3c8eab2009-01-21 18:50:57 +000038 where_tests, group_by='machine_hostname'):
39 where_params = {'test_idx': id}
showardeab66ce2009-12-23 00:03:56 +000040 for (attribute) in db.select(fields_params, 'tko_iteration_result',
mblighc3c8eab2009-01-21 18:50:57 +000041 where_params):
42 available_params.add("%s - %s" % (benchmark,
43 attribute[0]))
44 available_params = list(available_params)
45 #process form submit
46 cleared = ""
47 attributes = ""
48 params = []
49 attr = cgi.FieldStorage()
50 if attr.has_key("cleared"):
51 cleared = attr["cleared"].value
52 if attr.has_key("reset"):
53 cleared = ""
54 if attr.has_key("clear") or cleared == "true":
55 benchmark_key.clear()
56 cleared = "true"
57 else:
58 attributes = "|".join(["%s:%s" % (key, value[0]) for key, value in benchmark_key.items()])
59
60 if attr.has_key("add"):
61 val = attr["key"].value.split("-")
62 test = val[0].strip()
63 key = val[1].strip()
64 attributes = attr.getvalue("attributes", "")
65 tk = "%s:%s" % (test, key)
66 if len(attributes) == 0:
67 attributes = tk
68 elif attributes.find(tk) == -1:
69 attributes += "|%s" % (tk)
70
71 params = attributes.split("|")
72
73 print '<h1>Add tests</h1>'
74 display.print_add_test_form(available_params, attributes, cleared)
75
76 #convert params to a dictionary
77 for param in params:
78 test_attributes = param.split(":")
79 if not benchmark_key.has_key(test_attributes[0]):
80 benchmark_key[test_attributes[0]] = []
81 if benchmark_key[test_attributes[0]].count(test_attributes[1]) == 0:
82 benchmark_key[test_attributes[0]].append(test_attributes[1])
mbligh378e0ae2008-03-06 00:07:48 +000083
mbligh15110b72009-01-13 23:33:33 +000084 machine_idx = {}
85 benchmark_data = {}
mblighc3c8eab2009-01-21 18:50:57 +000086 for benchmark in benchmark_key:
mbligh15110b72009-01-13 23:33:33 +000087 fields = 'machine_idx,machine_hostname,count(status_word)'
88 where = { 'subdir': benchmark, 'status_word' : 'GOOD' }
89 data = {}
showardeab66ce2009-12-23 00:03:56 +000090 for (idx, machine, count) in db.select(fields, 'tko_test_view',
mblighc3c8eab2009-01-21 18:50:57 +000091 where, group_by='machine_hostname'):
mbligh15110b72009-01-13 23:33:33 +000092 data[machine] = count
93 machine_idx[machine] = idx
94 benchmark_data[benchmark] = data
mbligh378e0ae2008-03-06 00:07:48 +000095
mblighc3c8eab2009-01-21 18:50:57 +000096
mbligh15110b72009-01-13 23:33:33 +000097 print '<h1>Performance</h1>'
mbligh378e0ae2008-03-06 00:07:48 +000098
mblighc3c8eab2009-01-21 18:50:57 +000099 header_row = [ display.box('Benchmark', header=True) ]
100 for benchmark in benchmark_key:
101 header_row += [ display.box("%s - %s" % (re.sub(r'\.', '<br>', benchmark),key), header=True) for key in benchmark_key[benchmark] ]
102
mbligh15110b72009-01-13 23:33:33 +0000103 matrix = [header_row]
104 for machine in machine_idx:
105 row = [display.box(machine)]
mblighc3c8eab2009-01-21 18:50:57 +0000106 for benchmark in benchmark_key:
mbligh15110b72009-01-13 23:33:33 +0000107 count = benchmark_data[benchmark].get(machine, None)
108 if not count:
109 row.append(display.box(None))
110 continue
mblighc3c8eab2009-01-21 18:50:57 +0000111 for key in benchmark_key[re.sub(r'\..*', '', benchmark)]:
112 url = 'machine_test_attribute_graph.cgi'
113 url += '?machine=' + str(machine_idx[machine])
114 url += '&benchmark=' + benchmark
115 url += '&key=' + key
116 html = '<a href="%s">%d</a>' % (url, count)
117 row.append(display.box(html))
mbligh15110b72009-01-13 23:33:33 +0000118 matrix.append(row)
119 matrix.append(header_row)
mbligh378e0ae2008-03-06 00:07:48 +0000120
mbligh15110b72009-01-13 23:33:33 +0000121 display.print_table(matrix)
mbligh378e0ae2008-03-06 00:07:48 +0000122
123main()