mbligh | 378e0ae | 2008-03-06 00:07:48 +0000 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | print "Content-type: text/html\n" |
| 3 | import cgi, cgitb, os, sys, re |
| 4 | sys.stdout.flush() |
| 5 | cgitb.enable() |
| 6 | |
jadmanski | 22ab069 | 2008-05-01 22:22:51 +0000 | [diff] [blame] | 7 | import common |
| 8 | from autotest_lib.tko import db, display, frontend |
mbligh | 378e0ae | 2008-03-06 00:07:48 +0000 | [diff] [blame] | 9 | |
| 10 | db = db.db() |
| 11 | |
| 12 | benchmark_key = { |
mbligh | c3c8eab | 2009-01-21 18:50:57 +0000 | [diff] [blame] | 13 | 'kernbench' : ["elapsed"], |
| 14 | 'dbench' : ["throughput"], |
| 15 | 'tbench' : ["throughput"], |
mbligh | 378e0ae | 2008-03-06 00:07:48 +0000 | [diff] [blame] | 16 | } |
| 17 | |
| 18 | def main(): |
mbligh | 15110b7 | 2009-01-13 23:33:33 +0000 | [diff] [blame] | 19 | display.print_main_header() |
| 20 | ## it is table only; mouse hovering off |
mbligh | c3c8eab | 2009-01-21 18:50:57 +0000 | [diff] [blame] | 21 | display.set_brief_mode() |
mbligh | 378e0ae | 2008-03-06 00:07:48 +0000 | [diff] [blame] | 22 | |
mbligh | c3c8eab | 2009-01-21 18:50:57 +0000 | [diff] [blame] | 23 | ## getting available tests |
showard | eab66ce | 2009-12-23 00:03:56 +0000 | [diff] [blame] | 24 | rows = db.select('test', 'tko_tests', {}, distinct=True) |
mbligh | c3c8eab | 2009-01-21 18:50:57 +0000 | [diff] [blame] | 25 | all_benchmarks = [] |
mbligh | 15110b7 | 2009-01-13 23:33:33 +0000 | [diff] [blame] | 26 | for row in rows: |
| 27 | benchmark = row[0] |
| 28 | testname = re.sub(r'\..*', '', benchmark) |
mbligh | c3c8eab | 2009-01-21 18:50:57 +0000 | [diff] [blame] | 29 | 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' |
showard | eab66ce | 2009-12-23 00:03:56 +0000 | [diff] [blame] | 37 | for (id, count) in db.select(fields_tests, 'tko_test_view', |
mbligh | c3c8eab | 2009-01-21 18:50:57 +0000 | [diff] [blame] | 38 | where_tests, group_by='machine_hostname'): |
| 39 | where_params = {'test_idx': id} |
showard | eab66ce | 2009-12-23 00:03:56 +0000 | [diff] [blame] | 40 | for (attribute) in db.select(fields_params, 'tko_iteration_result', |
mbligh | c3c8eab | 2009-01-21 18:50:57 +0000 | [diff] [blame] | 41 | 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]) |
mbligh | 378e0ae | 2008-03-06 00:07:48 +0000 | [diff] [blame] | 83 | |
mbligh | 15110b7 | 2009-01-13 23:33:33 +0000 | [diff] [blame] | 84 | machine_idx = {} |
| 85 | benchmark_data = {} |
mbligh | c3c8eab | 2009-01-21 18:50:57 +0000 | [diff] [blame] | 86 | for benchmark in benchmark_key: |
mbligh | 15110b7 | 2009-01-13 23:33:33 +0000 | [diff] [blame] | 87 | fields = 'machine_idx,machine_hostname,count(status_word)' |
| 88 | where = { 'subdir': benchmark, 'status_word' : 'GOOD' } |
| 89 | data = {} |
showard | eab66ce | 2009-12-23 00:03:56 +0000 | [diff] [blame] | 90 | for (idx, machine, count) in db.select(fields, 'tko_test_view', |
mbligh | c3c8eab | 2009-01-21 18:50:57 +0000 | [diff] [blame] | 91 | where, group_by='machine_hostname'): |
mbligh | 15110b7 | 2009-01-13 23:33:33 +0000 | [diff] [blame] | 92 | data[machine] = count |
| 93 | machine_idx[machine] = idx |
| 94 | benchmark_data[benchmark] = data |
mbligh | 378e0ae | 2008-03-06 00:07:48 +0000 | [diff] [blame] | 95 | |
mbligh | c3c8eab | 2009-01-21 18:50:57 +0000 | [diff] [blame] | 96 | |
mbligh | 15110b7 | 2009-01-13 23:33:33 +0000 | [diff] [blame] | 97 | print '<h1>Performance</h1>' |
mbligh | 378e0ae | 2008-03-06 00:07:48 +0000 | [diff] [blame] | 98 | |
mbligh | c3c8eab | 2009-01-21 18:50:57 +0000 | [diff] [blame] | 99 | 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 | |
mbligh | 15110b7 | 2009-01-13 23:33:33 +0000 | [diff] [blame] | 103 | matrix = [header_row] |
| 104 | for machine in machine_idx: |
| 105 | row = [display.box(machine)] |
mbligh | c3c8eab | 2009-01-21 18:50:57 +0000 | [diff] [blame] | 106 | for benchmark in benchmark_key: |
mbligh | 15110b7 | 2009-01-13 23:33:33 +0000 | [diff] [blame] | 107 | count = benchmark_data[benchmark].get(machine, None) |
| 108 | if not count: |
| 109 | row.append(display.box(None)) |
| 110 | continue |
mbligh | c3c8eab | 2009-01-21 18:50:57 +0000 | [diff] [blame] | 111 | 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)) |
mbligh | 15110b7 | 2009-01-13 23:33:33 +0000 | [diff] [blame] | 118 | matrix.append(row) |
| 119 | matrix.append(header_row) |
mbligh | 378e0ae | 2008-03-06 00:07:48 +0000 | [diff] [blame] | 120 | |
mbligh | 15110b7 | 2009-01-13 23:33:33 +0000 | [diff] [blame] | 121 | display.print_table(matrix) |
mbligh | 378e0ae | 2008-03-06 00:07:48 +0000 | [diff] [blame] | 122 | |
| 123 | main() |