R中的内存配置文件-汇总工具 [英] Memory profiling in R - tools for summarizing

查看:175
本文介绍了R中的内存配置文件-汇总工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

R有一些用于内存分析的工具,例如Rprofmem(),带有选项"memory.profiling=TRUE"tracemem()Rprof().最后一个只能在对象上使用,因此对于跟踪对象被复制多少次很有用,但不能以功能为基础进行概述. Rprofmem应该能够做到这一点,但是即使是最简单的函数调用(如lm())的输出也可以提供500行以上的日志.我试图弄清楚Rprof("somefile.log",memory.profile=T)的实际作用,但我认为我并没有真正理解它.

R has some tools for memory profiling, like Rprofmem(), Rprof() with option "memory.profiling=TRUE" and tracemem(). The last one can only be used on objects, and hence is useful to follow how many times an object is copied, but doesn't give an overview on a function basis. Rprofmem should be able to do that, but the output of even the simplest function call like lm() gives over 500 lines of log. I tried to figure out what Rprof("somefile.log",memory.profile=T) actually does, but I don't think I really get it.

我最后找到的是托马斯·鲁姆利(Thomas Lumley)的消息,说,然后引用:

The last I could find was this message of Thomas Lumley, saying that, and I quote :

我还没有汇总输出的工具.

I do not yet have tools to summarize the output.

那是2006年.基于Rprofmem()Rprof()设置为TRUE的Rprof()的神秘输出还是其他工具,现在有没有机会提供一些不错的摘要?

This was in 2006. Any chance there are options for some nice summaries now, based on either Rprofmem(), the mysterious output of Rprof() with memory.profile set TRUE or any other tool?

推荐答案

profvis > 看起来像是该问题的解决方案.

profvis looks like the the solution to this question.

它会生成一个交互式 .html 文件(使用htmlwidgets),以显示您的代码配置文件.

It generates an interactive .html file (using htmlwidgets) showing the profiling of your code.

简介小插曲是其功能的很好指南.

The introduction vignette is a good guide on its capability.

直接从简介中开始,您将像这样使用它:

Taking directly from the introduction, you would use it like this:

devtools::install_github("rstudio/profvis")
library(profvis)

# Generate data
times <- 4e5
cols <- 150
data <- as.data.frame(x = matrix(rnorm(times * cols, mean = 5), ncol = cols))
data <- cbind(id = paste0("g", seq_len(times)), data)
profvis({
    data1 <- data   # Store in another variable for this run

    # Get column means
    means <- apply(data1[, names(data1) != "id"], 2, mean)

    # Subtract mean from each column
    for (i in seq_along(means)) {
        data1[, names(data1) != "id"][, i] <- data1[, names(data1) != "id"][, i] - means[i]
    }
}, height = "400px")

哪个给

这篇关于R中的内存配置文件-汇总工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆