blob: 79466a337002b39fb3bc9a4713d0129e38687620 [file] [log] [blame]
mbligh9f857922008-06-05 16:19:07 +00001import time, os, signal, re
mbligh53da18e2009-01-05 21:13:26 +00002from autotest_lib.client.bin import test, utils
mbligh9f857922008-06-05 16:19:07 +00003
mbligh2a3a3ea2006-04-22 22:53:23 +00004
5class tbench(test.test):
jadmanski0afbb632008-06-06 21:10:57 +00006 version = 2
mbligh2a3a3ea2006-04-22 22:53:23 +00007
mblighc5ddfd12008-08-04 17:15:00 +00008 def initialize(self):
9 self.job.require_gcc()
10
11
jadmanski0afbb632008-06-06 21:10:57 +000012 # http://samba.org/ftp/tridge/dbench/dbench-3.04.tar.gz
13 def setup(self, tarball = 'dbench-3.04.tar.gz'):
mbligh8b352852008-06-07 01:07:08 +000014 tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir)
mbligh53da18e2009-01-05 21:13:26 +000015 utils.extract_tarball_to_dir(tarball, self.srcdir)
jadmanski0afbb632008-06-06 21:10:57 +000016 os.chdir(self.srcdir)
mbligh2a3a3ea2006-04-22 22:53:23 +000017
Eric Li6f27d4f2010-09-29 10:55:17 -070018 utils.configure()
19 utils.make()
mbligh0662b152007-06-20 13:03:19 +000020
mblighc5ddfd12008-08-04 17:15:00 +000021
mbligh0cec9742008-08-28 18:22:46 +000022 def run_once(self, nprocs = None, args = ''):
jadmanski0afbb632008-06-06 21:10:57 +000023 # only supports combined server+client model at the moment
24 # should support separate I suppose, but nobody uses it
25 if not nprocs:
26 nprocs = self.job.cpu_count()
mbligh0cec9742008-08-28 18:22:46 +000027 args = args + ' %s' % nprocs
mbligha9991982006-05-25 18:32:43 +000028
jadmanski0afbb632008-06-06 21:10:57 +000029 pid = os.fork()
30 if pid: # parent
31 time.sleep(1)
32 client = self.srcdir + '/client.txt'
33 args = '-c ' + client + ' ' + '%s' % args
34 cmd = os.path.join(self.srcdir, "tbench") + " " + args
Eric Li861b2d52011-02-04 14:50:35 -080035 # Standard output is verbose and merely makes our debug logs huge
36 # so we don't retain it. It gets parsed for the results.
37 self.results = utils.run(cmd, stderr_tee=utils.TEE_TO_LOGS).stdout
jadmanski0afbb632008-06-06 21:10:57 +000038 os.kill(pid, signal.SIGTERM) # clean up the server
39 else: # child
40 server = self.srcdir + '/tbench_srv'
41 os.execlp(server, server)
mbligh0662b152007-06-20 13:03:19 +000042
43
mbligh34b297b2009-02-03 17:49:48 +000044 def postprocess_iteration(self):
jadmanski0afbb632008-06-06 21:10:57 +000045 pattern = re.compile(r"Throughput (.*?) MB/sec (.*?) procs")
mbligh34b297b2009-02-03 17:49:48 +000046 (throughput, procs) = pattern.findall(self.results)[0]
47 self.write_perf_keyval({'throughput':throughput, 'procs':procs})