本文整理汇总了Python中benchmark.Benchmark.run方法的典型用法代码示例。如果您正苦于以下问题:Python Benchmark.run方法的具体用法?Python Benchmark.run怎么用?Python Benchmark.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类benchmark.Benchmark
的用法示例。
在下文中一共展示了Benchmark.run方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Benchmark
# 需要导入模块: from benchmark import Benchmark [as 别名]
# 或者: from benchmark.Benchmark import run [as 别名]
from benchmark import Benchmark
modules = ['numpy','Numeric','numarray']
b = Benchmark(modules,
title='Casting a (10,10) integer array to float.',
runs=3,reps=10000)
N = [10,10]
b['numpy'] = ('b = a.astype(int)',
'a=numpy.zeros(shape=%s,dtype=float)' % N)
b['Numeric'] = ('b = a.astype("l")',
'a=Numeric.zeros(shape=%s,typecode="d")' % N)
b['numarray'] = ("b = a.astype('l')",
"a=numarray.zeros(shape=%s,typecode='d')" % N)
b.run()
示例2: Benchmark
# 需要导入模块: from benchmark import Benchmark [as 别名]
# 或者: from benchmark.Benchmark import run [as 别名]
return output
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')