[英]What unit of time does timeit return?
I don't know how to interpret the output from Python's timeit.timeit() function. 我不知道如何解释Python的timeit.timeit()函数的输出。 My code is as follows: 我的代码如下:
import timeit
setup = """
import pydash
list_of_objs = [
{},
{'a': 1, 'b': 2, 0: 0},
{'a': 1, 'c': 1, 'p': lambda x: x}
]
"""
print(timeit.timeit("pydash.filter_(list_of_objs, {'a': 1})", setup=setup))
The output from this is 11.85382745500101
. 这个输出是11.85382745500101
。 How do I interpret this number? 我该如何解释这个数字?
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. 它是运行测试所花费的总时间 (不计算设置),因此每次测试的平均时间是该数字除以number
参数,默认为1百万。
See the Time.timeit()
documentation : 请参阅Time.timeit()
文档 :
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 . 这将执行一次setup语句,然后返回执行主语句多次所需的时间,以秒为单位测量为浮点数 。 The argument is the number of times through the loop, defaulting to one million. 参数是通过循环的次数,默认为一百万。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.