diff options
author | mbligh <mbligh@592f7852-d20e-0410-864c-8624ca9c26a4> | 2009-01-21 18:50:57 +0000 |
---|---|---|
committer | mbligh <mbligh@592f7852-d20e-0410-864c-8624ca9c26a4> | 2009-01-21 18:50:57 +0000 |
commit | 6ab2818f0ae8132a449238580b79e82596be9f92 (patch) | |
tree | 15d337d17716d5370cbd021bcc1616fdc356a12c /tko/machine_benchmark.cgi | |
parent | eb93f84bba51d6d1731462fec77d6c6b98801668 (diff) |
This patch extends the functions of the old TKO system Performance section,
what you can reach at http://your_autotest_server/tko/machine_benchmark.cgi
- You can add benchmark test to the table with key values from a drop down list dynamically, so you don't need edit the machine_benchmark.cgi file manually.
- You can add one test with more key values to the table.
From: David Tengeri <dtengeri@gmail.com>
git-svn-id: svn://test.kernel.org/autotest/trunk@2663 592f7852-d20e-0410-864c-8624ca9c26a4
Diffstat (limited to 'tko/machine_benchmark.cgi')
-rwxr-xr-x | tko/machine_benchmark.cgi | 99 |
1 files changed, 76 insertions, 23 deletions
diff --git a/tko/machine_benchmark.cgi b/tko/machine_benchmark.cgi index 45cf5098..c9cd636f 100755 --- a/tko/machine_benchmark.cgi +++ b/tko/machine_benchmark.cgi @@ -10,58 +10,111 @@ from autotest_lib.tko import db, display, frontend db = db.db() benchmark_key = { -'kernbench' : 'elapsed', -'dbench' : 'throughput', -'tbench' : 'throughput', +'kernbench' : ["elapsed"], +'dbench' : ["throughput"], +'tbench' : ["throughput"], } def main(): display.print_main_header() ## it is table only; mouse hovering off - display.set_brief_mode() + display.set_brief_mode() - rows = db.select('test', 'tests', {}, distinct = True) - benchmarks = [] + ## getting available tests + rows = db.select('test', 'tests', {}, distinct=True) + all_benchmarks = [] for row in rows: benchmark = row[0] testname = re.sub(r'\..*', '', benchmark) - if not benchmark_key.has_key(testname): - continue - benchmarks.append(benchmark) - benchmarks = display.sort_tests(benchmarks) + all_benchmarks.append(benchmark) + all_benchmarks = display.sort_tests(all_benchmarks) + + available_params = set() + for benchmark in all_benchmarks: + fields_tests = 'test_idx, count(status_word)' + where_tests = { 'subdir': benchmark, 'status_word' : 'GOOD' } + fields_params = 'attribute' + for (id, count) in db.select(fields_tests, 'test_view', + where_tests, group_by='machine_hostname'): + where_params = {'test_idx': id} + for (attribute) in db.select(fields_params, 'iteration_result', + where_params): + available_params.add("%s - %s" % (benchmark, + attribute[0])) + available_params = list(available_params) + #process form submit + cleared = "" + attributes = "" + params = [] + attr = cgi.FieldStorage() + if attr.has_key("cleared"): + cleared = attr["cleared"].value + if attr.has_key("reset"): + cleared = "" + if attr.has_key("clear") or cleared == "true": + benchmark_key.clear() + cleared = "true" + else: + attributes = "|".join(["%s:%s" % (key, value[0]) for key, value in benchmark_key.items()]) + + if attr.has_key("add"): + val = attr["key"].value.split("-") + test = val[0].strip() + key = val[1].strip() + attributes = attr.getvalue("attributes", "") + tk = "%s:%s" % (test, key) + if len(attributes) == 0: + attributes = tk + elif attributes.find(tk) == -1: + attributes += "|%s" % (tk) + + params = attributes.split("|") + + print '<h1>Add tests</h1>' + display.print_add_test_form(available_params, attributes, cleared) + + #convert params to a dictionary + for param in params: + test_attributes = param.split(":") + if not benchmark_key.has_key(test_attributes[0]): + benchmark_key[test_attributes[0]] = [] + if benchmark_key[test_attributes[0]].count(test_attributes[1]) == 0: + benchmark_key[test_attributes[0]].append(test_attributes[1]) machine_idx = {} benchmark_data = {} - for benchmark in benchmarks: + for benchmark in benchmark_key: fields = 'machine_idx,machine_hostname,count(status_word)' where = { 'subdir': benchmark, 'status_word' : 'GOOD' } data = {} for (idx, machine, count) in db.select(fields, 'test_view', - where, group_by = 'machine_hostname'): + where, group_by='machine_hostname'): data[machine] = count machine_idx[machine] = idx benchmark_data[benchmark] = data - print '<h1>Performance</h1>' - header_row = [ display.box('Benchmark', header=True) ] - header_row += [ display.box(re.sub(r'\.', '<br>', benchmark), header=True) for benchmark in benchmarks ] + print '<h1>Performance</h1>' + header_row = [ display.box('Benchmark', header=True) ] + for benchmark in benchmark_key: + header_row += [ display.box("%s - %s" % (re.sub(r'\.', '<br>', benchmark),key), header=True) for key in benchmark_key[benchmark] ] + matrix = [header_row] for machine in machine_idx: row = [display.box(machine)] - for benchmark in benchmarks: + for benchmark in benchmark_key: count = benchmark_data[benchmark].get(machine, None) if not count: row.append(display.box(None)) continue - key = benchmark_key[re.sub(r'\..*', '', benchmark)] - url = 'machine_test_attribute_graph.cgi' - url += '?machine=' + str(machine_idx[machine]) - url += '&benchmark=' + benchmark - url += '&key=' + key - html = '<a href="%s">%d</a>' % (url, count) - row.append(display.box(html)) + for key in benchmark_key[re.sub(r'\..*', '', benchmark)]: + url = 'machine_test_attribute_graph.cgi' + url += '?machine=' + str(machine_idx[machine]) + url += '&benchmark=' + benchmark + url += '&key=' + key + html = '<a href="%s">%d</a>' % (url, count) + row.append(display.box(html)) matrix.append(row) matrix.append(header_row) |