def calculator(test, arg, n_runs, only_result,workpath=os.getcwd()):
w = []
for x in range(n_runs):
if only_result:
process = subprocess.Popen(
arg,
cwd=workpath,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
process.wait()
else:
process = subprocess.Popen(arg, cwd=workpath, shell=True)
process.wait()
with open(os.path.join(workpath,"Benchmark.txt")) as f:
for line in f.readlines():
w.append(float(line))
click.secho(
"\nThe results of the benchmark are (all speeds in items/sec) : \n",
bold=True)
click.secho(
"\nTest = '{0}' Iterations = '{1}'\n".format(test, n_runs),
bold=True)
click.secho(
"\nMean : {0} Median : {1} Std Dev : {2}\n".format(
statistics.mean(w),
statistics.median(w),
statistics.pstdev(w)),
bold=True)
os.remove(os.path.join(workpath,"Benchmark.txt"))
评论列表
文章目录