What unit of time does timeit return?

前端 未结 1 421
情书的邮戳
情书的邮戳 2021-01-03 17:51

I don\'t know how to interpret the output from Python\'s timeit.timeit() function. My code is as follows:

import timeit

setup = \"\"\"
import pydash
list_of         


        
相关标签:
1条回答
  • 2021-01-03 18:48

    The return value is seconds as a float.

    It is the total time taken to run the test (not counting the setup), so the average time per test is that number divided by the number argument, which defaults to 1 million.

    See the Time.timeit() documentation:

    Time number executions of the main statement. This executes the setup statement once, and then returns the time it takes to execute the main statement a number of times, measured in seconds as a float. The argument is the number of times through the loop, defaulting to one million.

    0 讨论(0)
提交回复
热议问题