2 print "Content-type: text/html\n"
3 import cgi
, cgitb
, os
, sys
, re
8 from autotest_lib
.tko
import db
, display
, frontend
13 'kernbench' : ["elapsed"],
14 'dbench' : ["throughput"],
15 'tbench' : ["throughput"],
19 display
.print_main_header()
20 ## it is table only; mouse hovering off
21 display
.set_brief_mode()
23 ## getting available tests
24 rows
= db
.select('test', 'tko_tests', {}, distinct
=True)
28 testname
= re
.sub(r
'\..*', '', benchmark
)
29 all_benchmarks
.append(benchmark
)
30 all_benchmarks
= display
.sort_tests(all_benchmarks
)
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'
37 for (id, count
) in db
.select(fields_tests
, 'tko_test_view',
38 where_tests
, group_by
='machine_hostname'):
39 where_params
= {'test_idx': id}
40 for (attribute
) in db
.select(fields_params
, 'tko_iteration_result',
42 available_params
.add("%s - %s" % (benchmark
,
44 available_params
= list(available_params
)
49 attr
= cgi
.FieldStorage()
50 if attr
.has_key("cleared"):
51 cleared
= attr
["cleared"].value
52 if attr
.has_key("reset"):
54 if attr
.has_key("clear") or cleared
== "true":
58 attributes
= "|".join(["%s:%s" % (key
, value
[0]) for key
, value
in benchmark_key
.items()])
60 if attr
.has_key("add"):
61 val
= attr
["key"].value
.split("-")
64 attributes
= attr
.getvalue("attributes", "")
65 tk
= "%s:%s" % (test
, key
)
66 if len(attributes
) == 0:
68 elif attributes
.find(tk
) == -1:
69 attributes
+= "|%s" % (tk
)
71 params
= attributes
.split("|")
73 print '<h1>Add tests</h1>'
74 display
.print_add_test_form(available_params
, attributes
, cleared
)
76 #convert params to a dictionary
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])
86 for benchmark
in benchmark_key
:
87 fields
= 'machine_idx,machine_hostname,count(status_word)'
88 where
= { 'subdir': benchmark
, 'status_word' : 'GOOD' }
90 for (idx
, machine
, count
) in db
.select(fields
, 'tko_test_view',
91 where
, group_by
='machine_hostname'):
93 machine_idx
[machine
] = idx
94 benchmark_data
[benchmark
] = data
97 print '<h1>Performance</h1>'
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
] ]
103 matrix
= [header_row
]
104 for machine
in machine_idx
:
105 row
= [display
.box(machine
)]
106 for benchmark
in benchmark_key
:
107 count
= benchmark_data
[benchmark
].get(machine
, None)
109 row
.append(display
.box(None))
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
116 html
= '<a href="%s">%d</a>' % (url
, count
)
117 row
.append(display
.box(html
))
119 matrix
.append(header_row
)
121 display
.print_table(matrix
)