Skip to content

Commit

Permalink
Merge pull request #118 from lionel-/add-simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
wch authored Aug 13, 2020
2 parents 51b0671 + 24bcecc commit 021ccfb
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ Suggests:
devtools,
shiny,
htmltools
RoxygenNote: 6.1.1
RoxygenNote: 7.1.0
URL: https://rstudio.github.io/profvis/
Encoding: UTF-8
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
profvis 0.3.6.9000
=============

* Added `simplify` argument. When `TRUE` (the default), the profiles are simplified using the new `filter.callframes` argument of R 4.0. This argument has no effect on older R versions.

* Fixed [#111](https://github.com/rstudio/profvis/issues/111): auto-scrolling to lines of code did not work in some browsers. ([#113](https://github.com/rstudio/profvis/pull/113))

profvis 0.3.6
Expand Down
17 changes: 14 additions & 3 deletions R/profvis.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
#' \code{torture = steps} helps prevent this, by making R trigger garbage
#' collection after every \code{torture} memory allocation step.
#'
#' @param simplify Whether to simplify the profiles by removing
#' intervening frames caused by lazy evaluation. This only has an
#' effect on R 4.0. See the \code{filter.callframes} argument of
#' \code{\link{Rprof}()}.
#'
#' @seealso \code{\link{print.profvis}} for printing options.
#' @seealso \code{\link{Rprof}} for more information about how the profiling
#' data is collected.
Expand Down Expand Up @@ -75,7 +80,7 @@
#' @export
profvis <- function(expr = NULL, interval = 0.01, prof_output = NULL,
prof_input = NULL, width = NULL, height = NULL,
split = c("h", "v"), torture = 0)
split = c("h", "v"), torture = 0, simplify = TRUE)
{
split <- match.arg(split)
expr_q <- substitute(expr)
Expand Down Expand Up @@ -128,8 +133,14 @@ profvis <- function(expr = NULL, interval = 0.01, prof_output = NULL,
on.exit(gctorture2(step = 0), add = TRUE)
}

Rprof(prof_output, interval = interval, line.profiling = TRUE,
gc.profiling = TRUE, memory.profiling = TRUE)
if (getRversion() >= "4.0.0") {
Rprof(prof_output, interval = interval, line.profiling = TRUE,
gc.profiling = TRUE, memory.profiling = TRUE,
filter.callframes = simplify)
} else {
Rprof(prof_output, interval = interval, line.profiling = TRUE,
gc.profiling = TRUE, memory.profiling = TRUE)
}
on.exit(Rprof(NULL), add = TRUE)
if (remove_on_exit)
on.exit(unlink(prof_output), add = TRUE)
Expand Down
3 changes: 1 addition & 2 deletions man/print.profvis.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 16 additions & 3 deletions man/profvis.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 021ccfb

Please sign in to comment.