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 | |
| 7 | tko = os.path.dirname(os.path.realpath(os.path.abspath(sys.argv[0]))) |
| 8 | sys.path.insert(0, tko) |
| 9 | import db, display, frontend |
| 10 | |
| 11 | db = db.db() |
| 12 | |
| 13 | benchmark_key = { |
| 14 | 'kernbench' : 'elapsed', |
| 15 | 'dbench' : 'throughput', |
| 16 | 'tbench' : 'throughput', |
| 17 | } |
| 18 | |
| 19 | def main(): |
| 20 | |
| 21 | display.print_main_header() |
| 22 | |
| 23 | rows = db.select('test', 'tests', {}, distinct = True) |
| 24 | benchmarks = [] |
| 25 | for row in rows: |
| 26 | benchmark = row[0] |
| 27 | testname = re.sub(r'\..*', '', benchmark) |
| 28 | if not benchmark_key.has_key(testname): |
| 29 | continue |
| 30 | benchmarks.append(benchmark) |
| 31 | benchmarks = display.sort_tests(benchmarks) |
| 32 | |
| 33 | machine_idx = {} |
| 34 | benchmark_data = {} |
| 35 | for benchmark in benchmarks: |
| 36 | fields = 'machine_idx,machine_hostname,count(status_word)' |
| 37 | where = { 'subdir': benchmark, 'status_word' : 'GOOD' } |
| 38 | data = {} |
| 39 | for (idx, machine, count) in db.select(fields, 'test_view', |
| 40 | where, group_by = 'machine_hostname'): |
| 41 | data[machine] = count |
| 42 | machine_idx[machine] = idx |
| 43 | benchmark_data[benchmark] = data |
| 44 | |
| 45 | print '<h1>Performance</h1>' |
| 46 | |
| 47 | header_row = [ display.box('Benchmark', header=True) ] |
| 48 | header_row += [ display.box(re.sub(r'\.', '<br>', benchmark), header=True) for benchmark in benchmarks ] |
| 49 | |
| 50 | matrix = [header_row] |
| 51 | for machine in machine_idx: |
| 52 | row = [display.box(machine)] |
| 53 | for benchmark in benchmarks: |
| 54 | count = benchmark_data[benchmark].get(machine, None) |
| 55 | if not count: |
| 56 | row.append(display.box(None)) |
| 57 | continue |
| 58 | key = benchmark_key[re.sub(r'\..*', '', benchmark)] |
| 59 | url = 'machine_test_attribute_graph.cgi' |
| 60 | url += '?machine=' + str(machine_idx[machine]) |
| 61 | url += '&benchmark=' + benchmark |
| 62 | url += '&key=' + key |
| 63 | html = '<a href="%s">%d</a>' % (url, count) |
| 64 | row.append(display.box(html)) |
| 65 | matrix.append(row) |
| 66 | matrix.append(header_row) |
| 67 | |
| 68 | display.print_table(matrix) |
| 69 | |
| 70 | main() |