python 计算程序运行耗时
datetime.datetime.now()获取的是当前日期
from datetime import datetime
startTime = datetime.now()
# ...
out = net(rgb)
endTime = datetime.now()
duringTime = endTime - startTime
print(duringTime)
显示毫秒
import datetime
startTime = datetime.datetime.now()
#这里调用你的方法
for i in range(1000):
print()
endTime = datetime.datetime.now()
durTime = 'funtion time use:%dms' % ((endTime -startTime ).seconds * 1000 + (endTime -startTime ).microseconds / 1000)
print(durTime)