标签:span 运行时间 运行 lis time模块 time bsp counter start
time模块下的perf_counter方法可用于精确计算程序运行的时间:
1 import time 2 3 start = time.perf_counter() 4 l = list(range(10000)) 5 end = time.perf_counter() 6 run_time= end - start 7 print(run_time) 8 9 ‘‘‘ 10 0.000290873000267311 11 ‘‘‘
perf_counter方法会把sleep的时间包含进去
1 import time 2 3 start = time.perf_counter() 4 l = list(range(10000)) 5 time.sleep(1) 6 end = time.perf_counter() 7 run_time= end - start 8 print(run_time) 9 10 ‘‘‘ 11 1.000621135000074 12 ‘‘‘
标签:span 运行时间 运行 lis time模块 time bsp counter start
原文地址:https://www.cnblogs.com/panlj/p/13940017.html