def test(self):
# only supports combined server+client model at the moment
# should support separate I suppose, but nobody uses it
nprocs = self.params.get('nprocs', default=commands.getoutput("nproc"))
args = self.params.get('args', default=None)
args = '%s %s' % (args, nprocs)
pid = os.fork()
if pid: # parent
client = os.path.join(self.sourcedir, 'client.txt')
args = '-c %s %s' % (client, args)
cmd = os.path.join(self.sourcedir, "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 = process.system_output(cmd, shell=True)
os.kill(pid, signal.SIGTERM) # clean up the server
else: # child
server = os.path.join(self.sourcedir, 'tbench_srv')
os.execlp(server, server)
pattern = re.compile(r"Throughput (.*?) MB/sec (.*?) procs")
(throughput, procs) = pattern.findall(self.results)[0]
self.log.info({'throughput': throughput, 'procs': procs})
tbench.py 文件源码
python
阅读 16
收藏 0
点赞 0
评论 0
评论列表
文章目录