gpt4 book ai didi

profiling - Julia:从代码中访问@time 计时和内存分配值

转载 作者:行者123 更新时间:2023-12-03 23:31:32 25 4
gpt4 key购买 nike

我正在分析我的 Julia 应用程序,特别是函数调用的执行时间和内存分配。我想将此信息自动存储到数据库中,以便它可以在没有监督的情况下运行。

我要存储的信息是@time返回的信息, 形式:

@time some_function()
86.278909 seconds (6.94 M allocations: 383.520 MB, 0.08% gc time)

是否可以从代码本身内部访问此信息,而不仅仅是打印出来?

我知道我可以使用 tic() 访问时间组件和 toq() ,但是内存分配呢?

最佳答案

有一个@timed为您提供所有这些信息的宏:

julia> @timed sleep(1)
(nothing,1.00417,624,0.0,Base.GC_Diff(624,0,0,13,0,0,0,0,0))

help?> @timed
@timed

A macro to execute an expression, and return the value of the expression, elapsed
time, total bytes allocated, garbage collection time, and an object with various
memory allocation counters.

关于profiling - Julia:从代码中访问@time 计时和内存分配值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34682144/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com