Wil*_*uck 3 python time timing
我主要是出于好奇而提出这个问题.我写了一些代码,这些代码正在做一些非常耗时的工作.所以,在执行我的workhorse函数之前,我把它包装成了对time.clock()的几次调用.它看起来像这样:
t1 = time.clock()
print this_function_takes_forever(how_long_parameter = 20)
t2 = time.clock()
print t2 - t1
Run Code Online (Sandbox Code Playgroud)
这很好.我的功能正确返回并t2 - t1给了我一个972.29或大约16分钟的结果.
但是,当我将代码更改为此时
t1 = time.clock()
print this_function_takes_forever(how_long_parameter = 80)
t2 = time.clock()
print t2 - t1
Run Code Online (Sandbox Code Playgroud)
我的功能仍然很好,但结果t2 - t1是:
None
-1741
Run Code Online (Sandbox Code Playgroud)
我很好奇实施细节导致了什么.None和负数都让我感到困惑.它与签名类型有关吗?这是None怎么解释的?