【问题标题】:How to measure execution time of entire jupyter notebook comprising of different cells in JULIA?如何测量由 JULIA 中不同单元组成的整个 jupyter notebook 的执行时间?
【发布时间】:2021-09-21 09:31:00
【问题描述】:

我在 Jupyter 笔记本中有一个用 JULIA 语言编写的脚本。脚本分为不同的单元格。我不仅要计算单行或单元格的执行时间,还要计算包含所有单元格的整个脚本的执行时间。在 Python 中,我可以使用

#In the beginning of script
import time
a = time.time()
...
...
#At the end of script
b= time.time()
b - a

我想要一些类似的东西来计算 JULIA 中整个脚本的执行时间。我尝试使用

@time begin
...
end

但是,这仅适用于单行或单元格,当我将语句放在脚本的开头和结尾时(如果它们位于不同的单元格中)似乎不起作用。如何获取包含所有单元格的整个脚本的执行时间?

【问题讨论】:

    标签: python time jupyter-notebook julia ijulia-notebook


    【解决方案1】:

    您也可以手动计算经过的时间:

    a = time()
    
    # ...
    
    b = time()
    println(b-a)
    

    【讨论】:

      【解决方案2】:

      我还找到了另一种方法:

      using Dates
      a = now()
      #...
      b = now()
      b - a
      

      【讨论】:

        猜你喜欢
        • 2017-09-04
        • 2019-09-06
        • 1970-01-01
        • 1970-01-01
        • 2018-01-08
        • 2018-09-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多