-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathtbench.py
48 lines (39 loc) · 1.69 KB
/
tbench.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import time
import os
import signal
import re
from autotest.client import test, utils
class tbench(test.test):
version = 2
def initialize(self):
self.job.require_gcc()
# http://samba.org/ftp/tridge/dbench/dbench-3.04.tar.gz
def setup(self, tarball='dbench-3.04.tar.gz'):
tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir)
utils.extract_tarball_to_dir(tarball, self.srcdir)
os.chdir(self.srcdir)
utils.configure()
utils.make()
def run_once(self, nprocs=None, args=''):
# only supports combined server+client model at the moment
# should support separate I suppose, but nobody uses it
if not nprocs:
nprocs = self.job.cpu_count()
args = args + ' %s' % nprocs
pid = os.fork()
if pid: # parent
time.sleep(1)
client = self.srcdir + '/client.txt'
args = '-c ' + client + ' ' + '%s' % args
cmd = os.path.join(self.srcdir, "tbench") + " " + args
# Standard output is verbose and merely makes our debug logs huge
# so we don't retain it. It gets parsed for the results.
self.results = utils.run(cmd, stderr_tee=utils.TEE_TO_LOGS).stdout
os.kill(pid, signal.SIGTERM) # clean up the server
else: # child
server = self.srcdir + '/tbench_srv'
os.execlp(server, server)
def postprocess_iteration(self):
pattern = re.compile(r"Throughput (.*?) MB/sec (.*?) procs")
(throughput, procs) = pattern.findall(self.results)[0]
self.write_perf_keyval({'throughput': throughput, 'procs': procs})