tbench.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:avocado-misc-tests 作者: avocado-framework-tests 项目源码 文件源码
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})
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号