Skip to content

Commit

Permalink
Fix typos and bugs (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
artemklevtsov committed Jun 26, 2016
1 parent ccc2b6b commit c9559fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions R/parse.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}

Expand Down
4 changes: 2 additions & 2 deletions R/prof-tree.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit c9559fb

Please sign in to comment.