1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
#!/usr/bin/python
# http://test.kernel.org/perf/kernbench.elm3b6.png
import cgi, cgitb, os, sys, re, subprocess
cgitb.enable()
Popen = subprocess.Popen
import common
from autotest_lib.tko import db, display, frontend, plotgraph
from autotest_lib.client.common_lib import kernel_versions
released_kernel = re.compile('2\.\d\.\d+(-smp-)[0-9]{3}\.[0-9]$')
rc_kernel = re.compile('2\.\d\.\d+(-smp-)[0-9]{3}\.[0-9]_rc[0-9]$')
db = db.db()
def main():
form = cgi.FieldStorage()
if form.has_key("benchmark_key"):
benchmark_key = form["benchmark_key"].value
# input is a list of benchmark:key values -- benchmark1:key1,...
# this loop separates this out into two lists
benchmark_idx = []
key_idx = []
for benchmark_key_pair in benchmark_key.split(','):
(benchmark, key) = benchmark_key_pair.split(':')
benchmark_idx.append(benchmark)
key_idx.append(key)
elif form.has_key("benchmark") and form.has_key("key"):
benchmarks = form["benchmark"].value
keys = form["key"].value
benchmark_idx = benchmarks.split(',')
key_idx = keys.split(',')
else:
# Ignore this for by setting benchmark_idx and key_idx to be
# empty lists.
benchmark_idx = []
key_idx = []
machine_idx = form["machine"].value
kernel = form["kernel"].value
if kernel == "released":
kernel = released_kernel
if kernel == "rc":
kernel = rc_kernel
machine = frontend.machine.select(db, {'hostname' : machine_idx})[0]
#get the machine type from machinename
for line in open('machines', 'r'):
words = line.rstrip().split('\t')
if words[0] == machine.hostname:
title = '%s (%s)' % (words[-1], machine.hostname)
else:
title = '%s' % machine.hostname
graph = plotgraph.gnuplot(title, 'Kernel', 'normalized throughput (%)', xsort = sort_kernels, size = "600,500")
for benchmark, key in zip(benchmark_idx, key_idx):
reference_value = None
data = {}
where = { 'subdir' : benchmark, 'machine_idx' : machine.idx , 'status' : 6}
#select the corresponding kernels and sort by the release version
kernels = set([])
kernels_sort = set([])
kernels_idx = set([])
for test in frontend.test.select(db, where):
if kernel == "all":
kernels.add(test.kernel().printable)
kernels_idx.add(str(test.kernel().idx))
elif kernel == "experimental":
if not re.match(released_kernel, test.kernel().printable)\
and not re.match(rc_kernel, test.kernel().printable):
kernels.add(test.kernel().printable)
kernels_idx.add(str(test.kernel().idx))
else:
if re.match(kernel, test.kernel().printable):
kernels.add(test.kernel().printable)
kernels_idx.add(str(test.kernel().idx))
kernels_sort = sort_kernels(list(kernels))
#get the base value for each benchmark
kernel_base = frontend.kernel.select(db, {'printable' : kernels_sort[0]})[0]
for test in frontend.test.select(db, { 'subdir' : benchmark, 'machine_idx' : machine.idx, 'kernel_idx' : kernel_base.idx}):
iterations = test.iterations()
if iterations.has_key(key):
reference_value = sum(iterations[key])/len(iterations[key])
break
wherein = { 'kernel_idx' : kernels_idx }
for test in frontend.test.select(db, where, wherein):
iterations = test.iterations()
if iterations.has_key(key):
# Maintain a list of every test result in data.
# Initialize this list, if it does not exist.
if not data.has_key(test.kernel().printable):
data[test.kernel().printable] = list()
if benchmark == "kernbench":
results = [((reference_value / i - 1)*100) for i in iterations[key]]
else:
results = [((i / reference_value - 1)*100) for i in iterations[key]]
data[test.kernel().printable].extend(results)
graph.add_dataset(benchmark+' ( '+key+' ) ',data)
graph.plot(cgi_header = True)
def sort_kernels(kernels):
return sorted(kernels, key = kernel_versions.version_encode)
main()
|