borgbench.py 文件源码

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

项目:borgbench 作者: dragetd 项目源码 文件源码
def runConfig(comp, cmin, cmax, cavg, data):
    # make sure there is no leftover repository. This will throw a warning on the shell if there is no folder, but it can be ignored
    subprocess.call(["rm", "-r", "/tmp/borgbench/"+comp])
    # run borg
    subprocess.call(["borg", "init", "-e", "none", "/tmp/borgbench/"+comp])
    start = timer()
    proc=subprocess.Popen(["borg", "create", "/tmp/borgbench/"+comp+"::test", "-v", "-s", "-C", comp, data], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    output = proc.stderr.read()
    duration = timer() - start
    # parse output
    m = re.match(".*This archive: +(\d+\.?\d+ ..) +(\d+\.?\d+ ..) +(\d+\.?\d+ ..).*Chunk index: +(\d+) +(\d+)", str(output))
    if m:
        print(comp+";"+str(cmin)+";"+str(cmax)+";"+str(cavg)+";"+m.group(1)+";"+m.group(2)+";"+m.group(3)+";"+m.group(4)+";"+m.group(5)+";"+str(duration))
    else:
        print("Error")
    # and clean up
    subprocess.call(["rm", "-r", "/tmp/borgbench/"+comp])


# Benchmark calls
# For speed reasons, this should be a tmpfs
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号