相关疑难解决方法(0)

将变量传递给函数时如何使用python timeit?

我正在努力使用timeit并且想知道是否有人有任何提示

基本上我有一个函数(我传递一个值),我想测试速度并创建它:

if __name__=='__main__':
    from timeit import Timer
    t = Timer(superMegaIntenseFunction(10))
    print t.timeit(number=1)
Run Code Online (Sandbox Code Playgroud)

但是当我运行它时,我得到了来自timeit模块的奇怪错误:

ValueError: stmt is neither a string nor callable
Run Code Online (Sandbox Code Playgroud)

如果我自己运行该功能,它可以正常工作.当我在模块中包装它时,我得到了错误(我尝试使用双引号而没有..sameoutput).

任何建议都会很棒!

谢谢!

python debugging benchmarking

73
推荐指数
3
解决办法
3万
查看次数

标签 统计

benchmarking ×1

debugging ×1

python ×1