diff --git a/R/parse.R b/R/parse.R index 8993996..b2eee66 100644 --- a/R/parse.R +++ b/R/parse.R @@ -12,8 +12,7 @@ parse_log <- function(filename) { calls <- unique(proflog, fromLast = TRUE) if (metadata$line.profiling) { ind <- grep("#File ", calls, fixed = TRUE) - fnames <- strsplit(calls[ind], ": ", fixed = TRUE) - fnames <- vapply(fnames, .subset2, 2L, FUN.VALUE = "") + fnames <- sub("#File \\d+: ?", "", calls[ind]) calls <- calls[-ind] tmp <- strsplit(gsub(".*(\\d#\\d).*", "\\1", calls), "#", fixed = TRUE) tmp <- lapply(tmp, as.integer) @@ -39,7 +38,7 @@ parse_log <- function(filename) { get_prof_info <- function(firstline) { list(line.profiling = grepl("line profiling", firstline, fixed = TRUE), memory.profiling = grepl("memory profiling", firstline, fixed = TRUE), - gc.profiling = grepl("gc profiling", firstline, fixed = TRUE), + gc.profiling = grepl("GC profiling", firstline, fixed = TRUE), interval = as.numeric(strsplit(firstline, "=", fixed = TRUE)[[1L]][2L]) / 1e6) } diff --git a/R/prof-tree.R b/R/prof-tree.R index 2b793bc..4657703 100644 --- a/R/prof-tree.R +++ b/R/prof-tree.R @@ -24,7 +24,7 @@ prof.tree <- function(filename = "Rprof.out") { traversal = "post-order", filterFun = isNotLeaf) tree$Do(function(node) node$env <- get_envname(node$name), filterFun = isNotRoot) tree$Do(function(node) node$name <- sprintf("`%s`", node$name), filterFun = isNotRoot) - if ("line" %in% res$fieldsAll) { + if ("line" %in% tree$fieldsAll) { tree$Do(function(node) node$file <- node$parent$file, traversal = "pre-order", filterFun = function(node) is.null(node$file)) tree$Do(function(node) node$line <- node$parent$line, @@ -42,7 +42,7 @@ prof.tree <- function(filename = "Rprof.out") { #' @export #' print.ProfTree <- function(x, limit = 25, ...) { - if ("line" %in% res$fieldsAll) + if ("line" %in% x$fieldsAll) NextMethod("print", x, "real", "percent", "env", "file", "line", pruneMethod = "dist", limit = limit) else