R中是否有一个包来监控资源(CPU、RAM等)的使用并在最后得到结果?

Is there a package in R to monitor the use of resources (CPU, RAM, etc) and get a result at the end?

我正在尝试查找 R Studio 中是否有任何包来开始监视我 PC 中资源(CPU、RAM 等)的使用。我这样做是因为我需要知道在 Rstudio 中运行的每个脚本的这些信息,所以我想知道是否有人对此有所了解。

谢谢!

您可以使用 bench 包。

> library(bench)
> 
> mark(source('example.R'), iterations = 1)
# A tibble: 1 x 13
  expression               min   median `itr/sec` mem_alloc `gc/sec` n_itr  n_gc total_time result           memory             time           gc              
  <bch:expr>          <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl> <int> <dbl>   <bch:tm> <list>           <list>             <list>         <list>          
1 source("example.R")    284us    284us     3516.    11.8KB        0     1     0      284us <named list [2]> <Rprofmem [5 x 3]> <bench_tm [1]> <tibble [1 x 3]>

这里我强制它只进行一次迭代。但您可以将其设置为您喜欢的任何数字以获得更准确的结果。