Python time.perf_counter()返回的小数秒到底是多少?

时间:2015-08-05 15:20:29

标签: python python-3.x time timing

这可能是一个愚蠢/明显的问题,但只是想确保我的预感是正确的。

我正在使用time.perf_counter()在Python3脚本中执行一些基本的性能计时:

start = time.perf_counter()
# some time consuming operation here
end = time.perf_counter()
elapsed = end - start

我会得到像9.774或36.903这样的值(当然还有更多的小数位)。我假设数字越大=时间越长,但这些数字到底意味着什么呢?例如。是1.23小数秒,仅1秒和.23分数秒

1 个答案:

答案 0 :(得分:5)

据我所知,“小数秒”仅表示具有小数部分的秒(相对于严格整数秒)。所以9.774意味着9秒加上774/1000秒。