Memory profiling in R - tools for summarizing
profvis
looks like the the solution to this question.
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")
Which gives
Check out profr -- it seems like exactly what you're looking for.