• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import os
2import re
3from autotest_lib.client.bin import test, utils
4
5test_name = 'compilebench'
6
7class compilebench(test.test):
8    version = 1
9
10    def setup(self, tarball = 'compilebench-0.6.tar.gz'):
11        self.tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir)
12        utils.extract_tarball_to_dir(self.tarball, self.srcdir)
13        os.chdir(self.srcdir)
14        utils.system('patch -p1 < ../compilebench.patch')
15
16
17    def run_once(self, dir=None, num_kernel_trees=10, num_random_runs=30):
18        if not dir:
19            dir = self.tmpdir
20
21        cmd = "%s -D %s -s %s -i %d -r %d" % (
22                         os.path.join(self.srcdir, test_name),
23                         dir,
24                         self.srcdir,
25                         num_kernel_trees,
26                         num_random_runs)
27
28        output = utils.system_output(cmd)
29
30        self.__format_results(output)
31
32
33    def __format_results(self, output):
34        keylist = {}
35
36        THROUGHPUT = "MB_s"
37        TIME       = "secs"
38
39        run_type_list = (
40            ('intial create', THROUGHPUT, 6, 'initial_create'),
41            ('create', THROUGHPUT, 5, 'new_create'),
42            ('patch', THROUGHPUT, 5, 'patch'),
43            ('compile', THROUGHPUT, 5, 'compile'),
44            ('clean', THROUGHPUT, 5, 'clean'),
45            ('read tree', THROUGHPUT, 6, 'read_tree'),
46            ('read compiled tree', THROUGHPUT, 7, 'read_compiled_tree'),
47            ('delete tree', TIME, 6, 'delete_tree'),
48            ('delete compiled tree', TIME, 6, 'delete_compiled_tree'),
49            ('stat tree', TIME, 6, 'stat_tree'),
50            ('stat compiled tree', TIME, 7, 'stat_compiled_tree'),
51        )
52
53# intial create total runs 10 avg 149.82 MB/s (user 0.63s sys 0.85s)
54# create total runs 5 avg 27.50 MB/s (user 0.62s sys 0.83s)
55# patch total runs 4 avg 15.01 MB/s (user 0.33s sys 0.63s)
56# compile total runs 7 avg 41.47 MB/s (user 0.14s sys 0.75s)
57# clean total runs 4 avg 697.77 MB/s (user 0.02s sys 0.08s)
58# read tree total runs 2 avg 23.68 MB/s (user 0.85s sys 1.59s)
59# read compiled tree total runs 1 avg 25.27 MB/s (user 0.98s sys 2.84s)
60# delete tree total runs 2 avg 1.48 seconds (user 0.35s sys 0.45s)
61# no runs for delete compiled tree
62# stat tree total runs 4 avg 1.46 seconds (user 0.35s sys 0.26s)
63# stat compiled tree total runs 1 avg 1.49 seconds (user 0.37s sys 0.29s)
64
65        for line in output.splitlines():
66            for pattern, result_type, position, tag in run_type_list:
67                if re.search('^%s' % pattern, line):
68                    l = line.split()
69                    value = l[position]
70
71                    s = "%s_%s" % (tag, result_type)
72
73                    keylist[s] = value
74                    break
75
76        self.write_perf_keyval(keylist)
77