summaryrefslogtreecommitdiff
path: root/tko/machine_aggr.cgi
blob: 5c23644cc07e754af18990821b5788256423c8a9 (plain)
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
#!/usr/bin/python

# http://test.kernel.org/perf/kernbench.elm3b6.png

import cgi, cgitb, os, sys, re, subprocess
cgitb.enable()
Popen = subprocess.Popen

tko = os.path.dirname(os.path.realpath(os.path.abspath(sys.argv[0])))
sys.path.insert(0, tko)
import db, display, frontend, plotgraph
client_bin = os.path.abspath(os.path.join(tko, '../client/bin'))
sys.path.insert(0, client_bin)
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()

	benchmarks = form["benchmark"].value
	keys = form["key"].value
	machine_idx = form["machine"].value
	kernel = form["kernel"].value
	if kernel == "released":
		kernel = released_kernel	
	if kernel == "rc":
		kernel = rc_kernel

	benchmark_idx = benchmarks.split(',')
	key_idx = keys.split(',')
	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):
				if benchmark == "kernbench":
					data[test.kernel().printable] = [((reference_value / i - 1)*100) for i in iterations[key]]
				else:
					data[test.kernel().printable] = [((i / reference_value - 1)*100) for i in iterations[key]]
		graph.add_dataset(benchmark+' ( '+key+' ) ',data)

	graph.plot(cgi_header = True)


def sort_kernels(kernels):
	return sorted(kernels, key = kernel_versions.version_encode)

main()