Less than 1 minute

手动统计

# 获取运行时间,秒
from time import *

start_time = time()				# 开始时间
# 睡眠5秒
sleep(5)
end_time = time()				# 结束时间
print(end_time - start_time)	# 经过秒数
# 5.000269889831543

pip install codetiming
from codetiming import Timer

@Timer(text="Dataset_flame Elapsed time: {:.4f} seconds")
def hello_fn():
    print('ok1')
    ...
    print('ok2')

hello_fn()
# ok1
# ok2
# Dataset_flame Elapsed time: 0.0003 seconds

codetiming 更多用法open in new window