OLD | NEW |
1 import time, os, signal, re | 1 import time, os, signal, re |
2 from autotest_lib.client.bin import test, utils | 2 from autotest_lib.client.bin import test, utils |
3 | 3 |
4 | 4 |
5 class tbench(test.test): | 5 class tbench(test.test): |
6 version = 2 | 6 version = 2 |
7 | 7 |
8 def initialize(self): | 8 def initialize(self): |
9 self.job.require_gcc() | 9 self.job.require_gcc() |
10 | 10 |
11 | 11 |
12 # http://samba.org/ftp/tridge/dbench/dbench-3.04.tar.gz | 12 # http://samba.org/ftp/tridge/dbench/dbench-3.04.tar.gz |
13 def setup(self, tarball = 'dbench-3.04.tar.gz'): | 13 def setup(self, tarball = 'dbench-3.04.tar.gz'): |
14 tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) | 14 tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) |
15 utils.extract_tarball_to_dir(tarball, self.srcdir) | 15 utils.extract_tarball_to_dir(tarball, self.srcdir) |
16 os.chdir(self.srcdir) | 16 os.chdir(self.srcdir) |
17 | 17 |
18 utils.system('./configure') | 18 utils.configure() |
19 utils.system('make') | 19 utils.make() |
20 | 20 |
21 | 21 |
22 def run_once(self, nprocs = None, args = ''): | 22 def run_once(self, nprocs = None, args = ''): |
23 # only supports combined server+client model at the moment | 23 # only supports combined server+client model at the moment |
24 # should support separate I suppose, but nobody uses it | 24 # should support separate I suppose, but nobody uses it |
25 if not nprocs: | 25 if not nprocs: |
26 nprocs = self.job.cpu_count() | 26 nprocs = self.job.cpu_count() |
27 args = args + ' %s' % nprocs | 27 args = args + ' %s' % nprocs |
28 | 28 |
29 pid = os.fork() | 29 pid = os.fork() |
30 if pid: # parent | 30 if pid: # parent |
31 time.sleep(1) | 31 time.sleep(1) |
32 client = self.srcdir + '/client.txt' | 32 client = self.srcdir + '/client.txt' |
33 args = '-c ' + client + ' ' + '%s' % args | 33 args = '-c ' + client + ' ' + '%s' % args |
34 cmd = os.path.join(self.srcdir, "tbench") + " " + args | 34 cmd = os.path.join(self.srcdir, "tbench") + " " + args |
35 self.results = utils.system_output(cmd, retain_output=True) | 35 self.results = utils.system_output(cmd, retain_output=True) |
36 os.kill(pid, signal.SIGTERM) # clean up the server | 36 os.kill(pid, signal.SIGTERM) # clean up the server |
37 else: # child | 37 else: # child |
38 server = self.srcdir + '/tbench_srv' | 38 server = self.srcdir + '/tbench_srv' |
39 os.execlp(server, server) | 39 os.execlp(server, server) |
40 | 40 |
41 | 41 |
42 def postprocess_iteration(self): | 42 def postprocess_iteration(self): |
43 pattern = re.compile(r"Throughput (.*?) MB/sec (.*?) procs") | 43 pattern = re.compile(r"Throughput (.*?) MB/sec (.*?) procs") |
44 (throughput, procs) = pattern.findall(self.results)[0] | 44 (throughput, procs) = pattern.findall(self.results)[0] |
45 self.write_perf_keyval({'throughput':throughput, 'procs':procs}) | 45 self.write_perf_keyval({'throughput':throughput, 'procs':procs}) |
OLD | NEW |