【发布时间】:2023-04-05 17:26:01
【问题描述】:
有没有办法从 system.time 中获取经过时间的数值?
我想测量我编写的一堆函数的运行时间。我这样称呼这些函数:
time_f1 <- system.time({
function_1(x,y,z)
and some other stuff
})
time_f2 <- system.time({
function_2(x,y,z)
and some other stuff
})
...
time_f1 和其他测量时间是 proc_time 类型的对象,我必须提取经过的时间。
是否有可能只直接获取经过时间的数值,所以我可以将它们存储在这样的向量中:
time_f[1] <- system.time::elapsed({
function_1(x,y,z)
and some other stuff
})
time_f[2] <- system.time::elapsed({
function_2(x,y,z)
and some other stuff
})
我知道system.time::elapsed 不存在,但有什么可比的吗?我在help() 中找不到system.time 或proc.time 的任何内容。
【问题讨论】:
-
我强烈建议使用
microbenchmark包进行此类测量!
标签: r