【发布时间】:2014-10-11 06:47:47
【问题描述】:
使用以下代码(Python 3.3.x、WinXp):
## debug function in a general/personal debug include file.
def timer_compare(time1, time2='', note='@', time3=time.clock()):
print('time1',time1)
time2 = time.clock() ## same as the function-passed time.clock() (just a little later)
print('time2',time2)
print('time3',time3)
exit(321)
主代码文件中使用的调用者代码:
time0 = time.clock()
## <other unrelated code.>
timer_compare(time0, time.clock())
我得到以下输出:
time1 0.0445(snip)
time2 0.0445(snip)
time3 0.0000043(snip) <- 4.385582001116343e-06
time3 这里似乎有办法降低数字。 (它看起来像是从一个刚刚创建的计时器案例中拉出来的。)
这里发生了什么/我错过了什么?
- 我知道 time.time() 通常比 time.clock() 更受欢迎/建议,以及为什么。
【问题讨论】:
标签: python python-3.x windows-xp