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