How to use python timeit when passing variables to functions?

后端 未结 5 803
迷失自我
迷失自我 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:43

    You should be passing a string. i.e.

    t = Timer('superMegaIntenseFunction(10)','from __main__ import superMegaIntenseFunction')
    

提交回复
热议问题