Python-Jupyter笔记本总经过时间

问题描述

我使用了https://stackoverflow.com/a/50384459/13535575中描述的有用提示获取每个Notebook单元的经过时间。 但是,如何在“全部运行”结束时获取笔记本的总经过时间?

提前发送, 骗子

解决方法

import time

def elapsed_time(start,end):
    hours,rem = divmod(end-start,3600)
    minutes,seconds = divmod(rem,60)
    print("Elapsed Time: {:0>2}:{:0>2}:{:05.2f}"
                .format(int(hours),int(minutes),seconds))

#Test

#First cell of your notebook 
start = time.time()
# Anothers cells ...

#Two last line of Notebook
end = time.time()
elapsed_time(start,end)