本文整理汇总了Python中benchmark.Benchmark.to_rst方法的典型用法代码示例。如果您正苦于以下问题:Python Benchmark.to_rst方法的具体用法?Python Benchmark.to_rst怎么用?Python Benchmark.to_rst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类benchmark.Benchmark
的用法示例。
在下文中一共展示了Benchmark.to_rst方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Benchmark
# 需要导入模块: from benchmark import Benchmark [as 别名]
# 或者: from benchmark.Benchmark import to_rst [as 别名]
if __name__ == "__main__":
from benchmark import Benchmark, BenchmarkSuite
setup = ""
statement = "lst = ['c'] * 100000"
bench = Benchmark(statement, setup, name='list with "*"')
statement = "lst = ['c' for x in xrange(100000)]"
bench2 = Benchmark(statement, setup, name="list with xrange")
statement = "lst = ['c' for x in range(100000)]"
bench3 = Benchmark(statement, setup, name="list with range")
results = bench3.run()
rst_text = bench3.to_rst(results)
with open("teste.rst", "w") as f:
f.write(rst_text)
suite = BenchmarkSuite()
suite.append(bench)
suite.append(bench2)
suite.append(bench3)
runner = BenchmarkRunner(suite, ".", "List Creation")
n_benchs, results = runner.run()
# print results
# fig = runner.plot_relative(results, horizontal=True)
# plt.savefig('%s_r.png' % runner.name, bbox_inches='tight')
# runner.plot_absolute(results, horizontal=False)