当前位置: 首页>>代码示例>>Python>>正文


Python Benchmark.run方法代码示例

本文整理汇总了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()
开发者ID:beiko-lab,项目名称:gengis,代码行数:19,代码来源:casting.py

示例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')
开发者ID:balarsen,项目名称:benchy,代码行数:32,代码来源:runner.py


注:本文中的benchmark.Benchmark.run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。