• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import os, re
2
3from autotest_lib.client.bin import utils, test
4
5class dbench(test.test):
6    version = 3
7
8    # http://samba.org/ftp/tridge/dbench/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)
11        utils.extract_tarball_to_dir(tarball, self.srcdir)
12        os.chdir(self.srcdir)
13
14        utils.system('patch -p1 < ../dbench_startup.patch')
15        utils.system('patch -p1 < ../dbench_ldflags.patch')
16        utils.configure()
17        utils.make()
18
19
20    def initialize(self):
21        self.job.require_gcc()
22        self.results = []
23        self.dbench = os.path.join(self.srcdir, 'dbench')
24
25
26    def run_once(self, dir='.', nprocs=None, seconds=600, args=''):
27        if not nprocs:
28            nprocs = self.job.cpu_count()
29        loadfile = os.path.join(self.srcdir, 'client.txt')
30        cmd = '%s %s %s -D %s -c %s -t %d' % (self.dbench, nprocs, args,
31                                              dir, loadfile, seconds)
32        self.results = utils.system_output(cmd, retain_output=True)
33
34
35    def postprocess_iteration(self):
36        pattern = re.compile(r"Throughput (.*?) MB/sec (.*?) procs")
37        (throughput, procs) = pattern.findall(self.results)[0]
38        self.write_perf_keyval({'throughput':throughput, 'procs':procs})
39