How to use python timeit when passing variables to functions?

后端 未结 5 806
迷失自我
迷失自我 2020-12-07 09:37

I\'m struggling with this using timeit and was wondering if anyone had any tips

Basically I have a function(that I pass a value to) that I want to test the speed of

5条回答
  •  醉话见心
    2020-12-07 09:47

    Make it a callable:

    if __name__=='__main__':
        from timeit import Timer
        t = Timer(lambda: superMegaIntenseFunction(10))
        print(t.timeit(number=1))
    

    Should work

提交回复
热议问题