OLD | NEW |
1 import os, re | 1 import os, re |
2 | 2 |
3 from autotest_lib.client.bin import utils, test | 3 from autotest_lib.client.bin import utils, test |
4 | 4 |
5 class dbench(test.test): | 5 class dbench(test.test): |
6 version = 3 | 6 version = 3 |
7 | 7 |
8 # http://samba.org/ftp/tridge/dbench/dbench-3.04.tar.gz | 8 # http://samba.org/ftp/tridge/dbench/dbench-3.04.tar.gz |
9 def setup(self, tarball='dbench-3.04.tar.gz'): | 9 def setup(self, tarball='dbench-3.04.tar.gz'): |
10 tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) | 10 tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) |
11 utils.extract_tarball_to_dir(tarball, self.srcdir) | 11 utils.extract_tarball_to_dir(tarball, self.srcdir) |
12 os.chdir(self.srcdir) | 12 os.chdir(self.srcdir) |
13 | 13 |
14 utils.system('patch -p1 < ../dbench_startup.patch') | 14 utils.system('patch -p1 < ../dbench_startup.patch') |
15 # CBUILD and CHOST is env vars used inside Chromium OS build environment | 15 utils.configure() |
16 # for cross compiling. | |
17 if 'CBUILD' in os.environ and 'CHOST' in os.environ: | |
18 config_params = '--build=%s --host=%s' % (os.environ['CBUILD'], | |
19 os.environ['CHOST']) | |
20 else: | |
21 config_params = '' | |
22 utils.system('./configure %s' % config_params) | |
23 utils.system('make') | 16 utils.system('make') |
24 | 17 |
25 | 18 |
26 def initialize(self): | 19 def initialize(self): |
27 self.job.require_gcc() | 20 self.job.require_gcc() |
28 self.results = [] | 21 self.results = [] |
29 self.dbench = os.path.join(self.srcdir, 'dbench') | 22 self.dbench = os.path.join(self.srcdir, 'dbench') |
30 | 23 |
31 | 24 |
32 def run_once(self, dir='.', nprocs=None, seconds=600, args=''): | 25 def run_once(self, dir='.', nprocs=None, seconds=600, args=''): |
33 if not nprocs: | 26 if not nprocs: |
34 nprocs = self.job.cpu_count() | 27 nprocs = self.job.cpu_count() |
35 loadfile = os.path.join(self.srcdir, 'client.txt') | 28 loadfile = os.path.join(self.srcdir, 'client.txt') |
36 cmd = '%s %s %s -D %s -c %s -t %d' % (self.dbench, nprocs, args, | 29 cmd = '%s %s %s -D %s -c %s -t %d' % (self.dbench, nprocs, args, |
37 dir, loadfile, seconds) | 30 dir, loadfile, seconds) |
38 self.results = utils.system_output(cmd, retain_output=True) | 31 self.results = utils.system_output(cmd, retain_output=True) |
39 | 32 |
40 | 33 |
41 def postprocess_iteration(self): | 34 def postprocess_iteration(self): |
42 pattern = re.compile(r"Throughput (.*?) MB/sec (.*?) procs") | 35 pattern = re.compile(r"Throughput (.*?) MB/sec (.*?) procs") |
43 (throughput, procs) = pattern.findall(self.results)[0] | 36 (throughput, procs) = pattern.findall(self.results)[0] |
44 self.write_perf_keyval({'throughput':throughput, 'procs':procs}) | 37 self.write_perf_keyval({'throughput':throughput, 'procs':procs}) |
OLD | NEW |