Python's time.clock() vs. time.time() accuracy?

后端 未结 16 1476
忘掉有多难
忘掉有多难 2020-11-22 08:22

Which is better to use for timing in Python? time.clock() or time.time()? Which one provides more accuracy?

for example:

start = time.clock()
... do          


        
16条回答
  •  太阳男子
    2020-11-22 08:49

    Others have answered re: time.time() vs. time.clock().

    However, if you're timing the execution of a block of code for benchmarking/profiling purposes, you should take a look at the timeit module.

提交回复
热议问题