From 0d23c9a4050bef6e50df3dda3caa525661705a88 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Mon, 1 Jul 2024 18:04:52 -0500 Subject: [PATCH] Upkeep 2024 (#147) * Re-document * `use_tidy_description()` * Eliminate `expect_snapshot0()`. No longer needed due to testthat changes * `use_roxygen_md()` * `use_tidy_github_actions()` * Increment version number to 0.3.8.9000 * Change maintainer to Hadley; update posit metadata * Use standard site template; update readme style --- .Rbuildignore | 3 ++ .github/workflows/R-CMD-check.yaml | 49 ++++++++++------------ .github/workflows/pkgdown.yaml | 41 +++++++++++++------ .github/workflows/pr-commands.yaml | 38 +++++++++-------- .github/workflows/test-coverage.yaml | 61 ++++++++++++++++++++++++++++ .gitignore | 1 + DESCRIPTION | 47 ++++++++++++--------- NEWS.md | 2 + R/parse.R | 4 +- R/pause.R | 6 +-- R/profvis.R | 50 +++++++++++++---------- R/shiny_module.R | 4 +- README.md | 9 ++-- _pkgdown.yml | 12 ++++++ codecov.yml | 14 +++++++ man/parse_rprof.Rd | 2 +- man/pause.Rd | 4 +- man/print.profvis.Rd | 5 +-- man/profvis.Rd | 36 ++++++++-------- man/profvis_ui.Rd | 7 ++-- man/renderProfvis.Rd | 2 +- tests/testthat/helper-profvis.R | 6 --- tests/testthat/test-rprof.R | 6 +-- 23 files changed, 261 insertions(+), 148 deletions(-) create mode 100644 .github/workflows/test-coverage.yaml create mode 100644 _pkgdown.yml create mode 100644 codecov.yml diff --git a/.Rbuildignore b/.Rbuildignore index deba5233..e078417f 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -10,3 +10,6 @@ ^cran-comments\.md$ ^scripts$ ^\.github$ +^codecov\.yml$ +^_pkgdown\.yml$ +^pkgdown$ diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 6ab68884..e712a216 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -1,4 +1,4 @@ -# Workflow derived from https://github.com/r-lib/actions/tree/master/examples +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help # # NOTE: This workflow is overkill for most R packages and @@ -12,6 +12,8 @@ on: name: R-CMD-check +permissions: read-all + jobs: R-CMD-check: runs-on: ${{ matrix.config.os }} @@ -22,49 +24,40 @@ jobs: fail-fast: false matrix: config: - - {os: macOS-latest, r: 'release'} + - {os: macos-latest, r: 'release'} - {os: windows-latest, r: 'release'} - # Use 3.6 to trigger usage of RTools35 - - {os: windows-latest, r: '3.6'} + # use 4.1 to check with rtools40's older compiler + - {os: windows-latest, r: '4.1'} - # Use older ubuntu to maximise backward compatibility - - {os: ubuntu-18.04, r: 'devel', http-user-agent: 'release'} - - {os: ubuntu-18.04, r: 'release'} - - {os: ubuntu-18.04, r: 'oldrel-1'} - - {os: ubuntu-18.04, r: 'oldrel-2'} - - {os: ubuntu-18.04, r: 'oldrel-3'} - - {os: ubuntu-18.04, r: 'oldrel-4'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} + - {os: ubuntu-latest, r: 'oldrel-2'} + - {os: ubuntu-latest, r: 'oldrel-3'} + - {os: ubuntu-latest, r: 'oldrel-4'} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} R_KEEP_PKG_SOURCE: yes steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - uses: r-lib/actions/setup-pandoc@v1 + - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.config.r }} http-user-agent: ${{ matrix.config.http-user-agent }} use-public-rspm: true - - uses: r-lib/actions/setup-r-dependencies@v1 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: rcmdcheck - - - uses: r-lib/actions/check-r-package@v1 - - - name: Show testthat output - if: always() - run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true - shell: bash + extra-packages: any::rcmdcheck + needs: check - - name: Upload check results - if: failure() - uses: actions/upload-artifact@main + - uses: r-lib/actions/check-r-package@v2 with: - name: ${{ runner.os }}-r${{ matrix.config.r }}-results - path: check + upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 59ae3087..c9f0165d 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -1,33 +1,50 @@ -# Workflow derived from https://github.com/r-lib/actions/tree/master/examples +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: branches: [main, master] - tags: ['*'] + pull_request: + branches: [main, master] + release: + types: [published] + workflow_dispatch: name: pkgdown +permissions: read-all + jobs: pkgdown: runs-on: ubuntu-latest + # Only restrict concurrency for non-PR jobs + concurrency: + group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - uses: r-lib/actions/setup-pandoc@v1 + - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-r@v2 with: use-public-rspm: true - - uses: r-lib/actions/setup-r-dependencies@v1 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: pkgdown + extra-packages: any::pkgdown, local::. needs: website - - name: Deploy package - run: | - git config --local user.name "$GITHUB_ACTOR" - git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" - Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)' + - name: Build site + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) + shell: Rscript {0} + + - name: Deploy to GitHub pages 🚀 + if: github.event_name != 'pull_request' + uses: JamesIves/github-pages-deploy-action@v4.5.0 + with: + clean: false + branch: gh-pages + folder: docs diff --git a/.github/workflows/pr-commands.yaml b/.github/workflows/pr-commands.yaml index 1cdafbf7..d1f76509 100644 --- a/.github/workflows/pr-commands.yaml +++ b/.github/workflows/pr-commands.yaml @@ -1,4 +1,4 @@ -# Workflow derived from https://github.com/r-lib/actions/tree/master/examples +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: issue_comment: @@ -6,30 +6,34 @@ on: name: Commands +permissions: read-all + jobs: document: - if: startsWith(github.event.comment.body, '/document') + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }} name: document runs-on: ubuntu-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - uses: r-lib/actions/pr-fetch@v1 + - uses: r-lib/actions/pr-fetch@v2 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-r@v2 with: use-public-rspm: true - - uses: r-lib/actions/setup-r-dependencies@v1 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: roxygen2 + extra-packages: any::roxygen2 + needs: pr-document - name: Document - run: Rscript -e 'roxygen2::roxygenise()' + run: roxygen2::roxygenise() + shell: Rscript {0} - name: commit run: | @@ -38,30 +42,32 @@ jobs: git add man/\* NAMESPACE git commit -m 'Document' - - uses: r-lib/actions/pr-push@v1 + - uses: r-lib/actions/pr-push@v2 with: repo-token: ${{ secrets.GITHUB_TOKEN }} style: - if: startsWith(github.event.comment.body, '/style') + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/style') }} name: style runs-on: ubuntu-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - uses: r-lib/actions/pr-fetch@v1 + - uses: r-lib/actions/pr-fetch@v2 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-r@v2 - name: Install dependencies - run: Rscript -e 'install.packages("styler")' + run: install.packages("styler") + shell: Rscript {0} - name: Style - run: Rscript -e 'styler::style_pkg()' + run: styler::style_pkg() + shell: Rscript {0} - name: commit run: | @@ -70,6 +76,6 @@ jobs: git add \*.R git commit -m 'Style' - - uses: r-lib/actions/pr-push@v1 + - uses: r-lib/actions/pr-push@v2 with: repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 00000000..fefc52e2 --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -0,0 +1,61 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: test-coverage + +permissions: read-all + +jobs: + test-coverage: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::covr, any::xml2 + needs: coverage + + - name: Test coverage + run: | + cov <- covr::package_coverage( + quiet = FALSE, + clean = FALSE, + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") + ) + covr::to_cobertura(cov) + shell: Rscript {0} + + - uses: codecov/codecov-action@v4 + with: + fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }} + file: ./cobertura.xml + plugin: noop + disable_search: true + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Show testthat output + if: always() + run: | + ## -------------------------------------------------------------------- + find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + + - name: Upload test results + if: failure() + uses: actions/upload-artifact@v4 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package diff --git a/.gitignore b/.gitignore index 94302710..809b55fa 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ inst/doc src/*.o src/*.so +docs diff --git a/DESCRIPTION b/DESCRIPTION index 0e3b1594..4a9da352 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,18 +1,28 @@ Package: profvis Title: Interactive Visualizations for Profiling R Code -Version: 0.3.8 +Version: 0.3.8.9000 Authors@R: c( - person("Winston", "Chang", email = "winston@rstudio.com", role = c("aut", "cre")), - person("Javier", "Luraschi", email = "javier@rstudio.com", role = "aut"), + person("Hadley", "Wickham", , "hadley@posit.co", role = c("aut", "cre")), + person("Winston", "Chang", role = "aut"), + person("Javier", "Luraschi", role = "aut"), person("Timothy", "Mastny", role = "aut"), - person(family = "RStudio", role = "cph"), - person(family = "jQuery Foundation", role = "cph", comment = "jQuery library"), - person(family = "jQuery contributors", role = c("ctb", "cph"), comment = "jQuery library; authors listed in inst/www/shared/jquery-AUTHORS.txt"), - person("Mike", "Bostock", role = c("ctb", "cph"), comment = "D3 library"), - person(family = "D3 contributors", role = "ctb", comment = "D3 library"), - person("Ivan", "Sagalaev", role = c("ctb", "cph"), comment = "highlight.js library") - ) + person("Posit Software, PBC", role = c("cph", "fnd")), + person(, "jQuery Foundation", role = "cph", + comment = "jQuery library"), + person(, "jQuery contributors", role = c("ctb", "cph"), + comment = "jQuery library; authors listed in inst/www/shared/jquery-AUTHORS.txt"), + person("Mike", "Bostock", role = c("ctb", "cph"), + comment = "D3 library"), + person(, "D3 contributors", role = "ctb", + comment = "D3 library"), + person("Ivan", "Sagalaev", role = c("ctb", "cph"), + comment = "highlight.js library") + ) Description: Interactive visualizations for profiling R code. +License: GPL-3 | file LICENSE +URL: https://rstudio.github.io/profvis/, + https://github.com/rstudio/profvis +BugReports: https://github.com/rstudio/profvis/issues Depends: R (>= 3.0) Imports: @@ -21,17 +31,16 @@ Imports: rlang (>= 0.4.9), stringr, vctrs -License: GPL-3 | file LICENSE Suggests: - knitr, + devtools, ggplot2, + htmltools, + knitr, rmarkdown, - testthat (>= 3.0.0), - devtools, shiny, - htmltools -RoxygenNote: 7.2.3 -URL: https://rstudio.github.io/profvis/, https://github.com/rstudio/profvis -BugReports: https://github.com/rstudio/profvis/issues -Encoding: UTF-8 + testthat (>= 3.0.0) +Config/Needs/website: tidyverse/tidytemplate Config/testthat/edition: 3 +Encoding: UTF-8 +Roxygen: list(markdown = TRUE) +RoxygenNote: 7.3.1 diff --git a/NEWS.md b/NEWS.md index 26c94998..963a8dc5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,5 @@ +# profvis (development version) + profvis 0.3.8 ============================= diff --git a/R/parse.R b/R/parse.R index 706c5e9e..5eae6079 100644 --- a/R/parse.R +++ b/R/parse.R @@ -1,9 +1,9 @@ #' Parse Rprof output file for use with profvis #' -#' @param path Path to the \code{\link{Rprof}} output file. +#' @param path Path to the [Rprof()] output file. #' @param expr_source If any source refs in the profiling output have an empty #' filename, that means they refer to code executed at the R console. This -#' code can be captured and passed (as a string) as the \code{expr_source} +#' code can be captured and passed (as a string) as the `expr_source` #' argument. #' @import stringr #' @export diff --git a/R/pause.R b/R/pause.R index 48ab36ec..9ac80568 100644 --- a/R/pause.R +++ b/R/pause.R @@ -1,9 +1,9 @@ #' Pause an R process #' #' This function pauses an R process for some amount of time. It differs from -#' \code{\link{Sys.sleep}} in that time spent in \code{pause} will show up in -#' profiler data. Another difference is that \code{pause} uses up 100\% of a CPU, -#' whereas \code{Sys.sleep} does not. +#' [Sys.sleep()] in that time spent in `pause` will show up in +#' profiler data. Another difference is that `pause` uses up 100\% of a CPU, +#' whereas `Sys.sleep` does not. #' #' @examples #' # Wait for 0.5 seconds diff --git a/R/profvis.R b/R/profvis.R index 8c7e8f1e..757ceeef 100644 --- a/R/profvis.R +++ b/R/profvis.R @@ -3,41 +3,41 @@ #' This function will run an R expression with profiling, and then return an #' htmlwidget for interactively exploring the profiling data. #' -#' An alternate way to use \code{profvis} is to separately capture the profiling -#' data to a file using \code{\link{Rprof}()}, and then pass the path to the -#' corresponding data file as the \code{prof_input} argument to -#' \code{profvis()}. +#' An alternate way to use `profvis` is to separately capture the profiling +#' data to a file using [Rprof()], and then pass the path to the +#' corresponding data file as the `prof_input` argument to +#' `profvis()`. #' -#' @param expr Expression to profile. Not compatible with \code{prof_input}. +#' @param expr Expression to profile. Not compatible with `prof_input`. #' The expression is repeatedly evaluated until `Rprof()` produces #' an output. It can _be_ a quosure injected with [rlang::inject()] but #' it cannot _contain_ injected quosures. #' @param interval Interval for profiling samples, in seconds. Values less than #' 0.005 (5 ms) will probably not result in accurate timings #' @param prof_output Name of an Rprof output file or directory in which to save -#' profiling data. If \code{NULL} (the default), a temporary file will be used +#' profiling data. If `NULL` (the default), a temporary file will be used #' and automatically removed when the function exits. For a directory, a #' random filename is used. #' -#' @param prof_input The path to an \code{\link{Rprof}} data file. Not -#' compatible with \code{expr} or \code{prof_output}. +#' @param prof_input The path to an [Rprof()] data file. Not +#' compatible with `expr` or `prof_output`. #' @param width Width of the htmlwidget. #' @param height Height of the htmlwidget -#' @param split Direction of split. Either \code{"v"} (the default) for -#' vertical, or \code{"h"} for horizontal. This is the orientation of the +#' @param split Direction of split. Either `"v"` (the default) for +#' vertical, or `"h"` for horizontal. This is the orientation of the #' split bar. -#' @param torture Triggers garbage collection after every \code{torture} memory +#' @param torture Triggers garbage collection after every `torture` memory #' allocation call. #' #' Note that memory allocation is only approximate due to the nature of the #' sampling profiler and garbage collection: when garbage collection triggers, #' memory allocations will be attributed to different lines of code. Using -#' \code{torture = steps} helps prevent this, by making R trigger garbage -#' collection after every \code{torture} memory allocation step. +#' `torture = steps` helps prevent this, by making R trigger garbage +#' collection after every `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}()}. +#' effect on R 4.0. See the `filter.callframes` argument of +#' [Rprof()]. #' @param rerun If `TRUE`, `Rprof()` is run again with `expr` until a #' profile is actually produced. This is useful for the cases where #' `expr` returns too quickly, before R had time to sample a @@ -45,8 +45,8 @@ #' profiles. In this case, `profvis()` reruns `expr` until the #' regexp matches the modal value of the profile stacks. #' -#' @seealso \code{\link{print.profvis}} for printing options. -#' @seealso \code{\link{Rprof}} for more information about how the profiling +#' @seealso [print.profvis()] for printing options. +#' @seealso [Rprof()] for more information about how the profiling #' data is collected. #' #' @examples @@ -86,9 +86,15 @@ #' @import htmlwidgets #' @importFrom utils Rprof #' @export -profvis <- function(expr = NULL, interval = 0.01, prof_output = NULL, - prof_input = NULL, width = NULL, height = NULL, - split = c("h", "v"), torture = 0, simplify = TRUE, +profvis <- function(expr = NULL, + interval = 0.01, + prof_output = NULL, + prof_input = NULL, + width = NULL, + height = NULL, + split = c("h", "v"), + torture = 0, + simplify = TRUE, rerun = FALSE) { split <- match.arg(split) c(expr_q, env) %<-% enquo0_list(expr) @@ -282,8 +288,8 @@ profvisOutput <- function(outputId, width = '100%', height = '600px'){ #' Widget render function for use in Shiny #' #' @param expr An expression that returns a profvis object. -#' @param env The environment in which to evaluate \code{expr}. -#' @param quoted Is \code{expr} a quoted expression (with \code{\link{quote}()})? +#' @param env The environment in which to evaluate `expr`. +#' @param quoted Is `expr` a quoted expression (with [quote()])? #' #' @export renderProfvis <- function(expr, env = parent.frame(), quoted = FALSE) { diff --git a/R/shiny_module.R b/R/shiny_module.R index 98f98e22..300e3612 100644 --- a/R/shiny_module.R +++ b/R/shiny_module.R @@ -16,7 +16,7 @@ #' For more details on how to invoke Shiny modules, see [this #' article](https://shiny.rstudio.com/articles/modules.html). #' -#' @param id Output id from \code{profvis_server}. +#' @param id Output id from `profvis_server`. #' #' @examples #' # In order to avoid "Hit to see next plot" prompts, @@ -75,7 +75,7 @@ profvis_ui <- function(id) { } #' @param input,output,session Arguments provided by -#' \code{\link[shiny]{callModule}}. +#' [shiny::callModule()]. #' @param dir Output directory to save Rprof files. #' #' @rdname profvis_ui diff --git a/README.md b/README.md index 42c8f4c3..d55e1263 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ -Profvis +profvis ======= -[![R-CMD-check](https://github.com/rstudio/profvis/workflows/R-CMD-check/badge.svg)](https://github.com/rstudio/profvis/actions) +[![R-CMD-check](https://github.com/r-lib/profvis/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/profvis/actions/workflows/R-CMD-check.yaml) +[![Codecov test coverage](https://codecov.io/gh/r-lib/profvis/graph/badge.svg)](https://codecov.io/gh/r-lib/profvis) Profvis is a tool for visualizing code profiling data from R. It creates a web page which provides a graphical interface for exploring the data. @@ -14,10 +15,6 @@ Profvis is a tool for visualizing code profiling data from R. It creates a web p install.packages("profvis") ``` -## Documentation - -See the [documentation site](https://rstudio.github.io/profvis/). - ## Example To run code with profiling, wrap the expression in `profvis()`. By default, this will result in the interactive profile visualizer opening in a web browser. diff --git a/_pkgdown.yml b/_pkgdown.yml new file mode 100644 index 00000000..37a816ca --- /dev/null +++ b/_pkgdown.yml @@ -0,0 +1,12 @@ +url: https://profvis.r-lib.org + +template: + package: tidytemplate + bootstrap: 5 + + includes: + in_header: | + + +development: + mode: auto diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..04c55859 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,14 @@ +comment: false + +coverage: + status: + project: + default: + target: auto + threshold: 1% + informational: true + patch: + default: + target: auto + threshold: 1% + informational: true diff --git a/man/parse_rprof.Rd b/man/parse_rprof.Rd index 9bd1d26a..81329e15 100644 --- a/man/parse_rprof.Rd +++ b/man/parse_rprof.Rd @@ -7,7 +7,7 @@ parse_rprof(path = "Rprof.out", expr_source = NULL) } \arguments{ -\item{path}{Path to the \code{\link{Rprof}} output file.} +\item{path}{Path to the \code{\link[=Rprof]{Rprof()}} output file.} \item{expr_source}{If any source refs in the profiling output have an empty filename, that means they refer to code executed at the R console. This diff --git a/man/pause.Rd b/man/pause.Rd index 6f3c6695..00cc2bc1 100644 --- a/man/pause.Rd +++ b/man/pause.Rd @@ -11,8 +11,8 @@ pause(seconds) } \description{ This function pauses an R process for some amount of time. It differs from -\code{\link{Sys.sleep}} in that time spent in \code{pause} will show up in -profiler data. Another difference is that \code{pause} uses up 100\% of a CPU, +\code{\link[=Sys.sleep]{Sys.sleep()}} in that time spent in \code{pause} will show up in +profiler data. Another difference is that \code{pause} uses up 100\\% of a CPU, whereas \code{Sys.sleep} does not. } \examples{ diff --git a/man/print.profvis.Rd b/man/print.profvis.Rd index 5032064e..8044d64e 100644 --- a/man/print.profvis.Rd +++ b/man/print.profvis.Rd @@ -19,10 +19,9 @@ vertical, or \code{"h"} for horizontal. This is the orientation of the split bar.} -\item{aggregate}{If `TRUE`, the profiled stacks are aggregated by +\item{aggregate}{If \code{TRUE}, the profiled stacks are aggregated by name. This makes it easier to see the big picture. Set your own -global default for this argument with `options(profvis.aggregate -= )`.} +global default for this argument with \code{options(profvis.aggregate = )}.} } \description{ Print a profvis object diff --git a/man/profvis.Rd b/man/profvis.Rd index 8764099c..114a3344 100644 --- a/man/profvis.Rd +++ b/man/profvis.Rd @@ -19,9 +19,9 @@ profvis( } \arguments{ \item{expr}{Expression to profile. Not compatible with \code{prof_input}. -The expression is repeatedly evaluated until `Rprof()` produces -an output. It can _be_ a quosure injected with [rlang::inject()] but -it cannot _contain_ injected quosures.} +The expression is repeatedly evaluated until \code{Rprof()} produces +an output. It can \emph{be} a quosure injected with \code{\link[rlang:inject]{rlang::inject()}} but +it cannot \emph{contain} injected quosures.} \item{interval}{Interval for profiling samples, in seconds. Values less than 0.005 (5 ms) will probably not result in accurate timings} @@ -31,7 +31,7 @@ profiling data. If \code{NULL} (the default), a temporary file will be used and automatically removed when the function exits. For a directory, a random filename is used.} -\item{prof_input}{The path to an \code{\link{Rprof}} data file. Not +\item{prof_input}{The path to an \code{\link[=Rprof]{Rprof()}} data file. Not compatible with \code{expr} or \code{prof_output}.} \item{width}{Width of the htmlwidget.} @@ -43,24 +43,24 @@ vertical, or \code{"h"} for horizontal. This is the orientation of the split bar.} \item{torture}{Triggers garbage collection after every \code{torture} memory - allocation call. +allocation call. - Note that memory allocation is only approximate due to the nature of the - sampling profiler and garbage collection: when garbage collection triggers, - memory allocations will be attributed to different lines of code. Using - \code{torture = steps} helps prevent this, by making R trigger garbage - collection after every \code{torture} memory allocation step.} +Note that memory allocation is only approximate due to the nature of the +sampling profiler and garbage collection: when garbage collection triggers, +memory allocations will be attributed to different lines of code. Using +\code{torture = steps} helps prevent this, by making R trigger garbage +collection after every \code{torture} memory allocation step.} \item{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}()}.} +\code{\link[=Rprof]{Rprof()}}.} -\item{rerun}{If `TRUE`, `Rprof()` is run again with `expr` until a +\item{rerun}{If \code{TRUE}, \code{Rprof()} is run again with \code{expr} until a profile is actually produced. This is useful for the cases where -`expr` returns too quickly, before R had time to sample a +\code{expr} returns too quickly, before R had time to sample a profile. Can also be a string containing a regexp to match -profiles. In this case, `profvis()` reruns `expr` until the +profiles. In this case, \code{profvis()} reruns \code{expr} until the regexp matches the modal value of the profile stacks.} } \description{ @@ -69,7 +69,7 @@ htmlwidget for interactively exploring the profiling data. } \details{ An alternate way to use \code{profvis} is to separately capture the profiling -data to a file using \code{\link{Rprof}()}, and then pass the path to the +data to a file using \code{\link[=Rprof]{Rprof()}}, and then pass the path to the corresponding data file as the \code{prof_input} argument to \code{profvis()}. } @@ -109,8 +109,8 @@ browseURL("profile.html") } } \seealso{ -\code{\link{print.profvis}} for printing options. +\code{\link[=print.profvis]{print.profvis()}} for printing options. -\code{\link{Rprof}} for more information about how the profiling - data is collected. +\code{\link[=Rprof]{Rprof()}} for more information about how the profiling +data is collected. } diff --git a/man/profvis_ui.Rd b/man/profvis_ui.Rd index 2d6bfacc..01507cf0 100644 --- a/man/profvis_ui.Rd +++ b/man/profvis_ui.Rd @@ -13,7 +13,7 @@ profvis_server(input, output, session, dir = ".") \item{id}{Output id from \code{profvis_server}.} \item{input, output, session}{Arguments provided by -\code{\link[shiny]{callModule}}.} +\code{\link[shiny:callModule]{shiny::callModule()}}.} \item{dir}{Output directory to save Rprof files.} } @@ -26,14 +26,13 @@ only, and not included in production apps! } \details{ The usual way to use Profvis with Shiny is to simply call -`profvis(shiny::runApp())`, but this may not always be possible or desirable: +\code{profvis(shiny::runApp())}, but this may not always be possible or desirable: first, if you only want to profile a particular interaction in the Shiny app and not capture all the calculations involved in starting up the app and getting it into the correct state; and second, if you're trying to profile an application that's been deployed to a server. -For more details on how to invoke Shiny modules, see [this -article](https://shiny.rstudio.com/articles/modules.html). +For more details on how to invoke Shiny modules, see \href{https://shiny.rstudio.com/articles/modules.html}{this article}. } \examples{ # In order to avoid "Hit to see next plot" prompts, diff --git a/man/renderProfvis.Rd b/man/renderProfvis.Rd index 22f4ded0..45118723 100644 --- a/man/renderProfvis.Rd +++ b/man/renderProfvis.Rd @@ -11,7 +11,7 @@ renderProfvis(expr, env = parent.frame(), quoted = FALSE) \item{env}{The environment in which to evaluate \code{expr}.} -\item{quoted}{Is \code{expr} a quoted expression (with \code{\link{quote}()})?} +\item{quoted}{Is \code{expr} a quoted expression (with \code{\link[=quote]{quote()}})?} } \description{ Widget render function for use in Shiny diff --git a/tests/testthat/helper-profvis.R b/tests/testthat/helper-profvis.R index d8febd0f..11234e69 100644 --- a/tests/testthat/helper-profvis.R +++ b/tests/testthat/helper-profvis.R @@ -12,12 +12,6 @@ cat_rprof <- function(expr, ..., rerun = "pause") { cat(paste0(out, "\n")) } -expect_snapshot0 <- function(expr, cran = TRUE) { - # Prevent `expect_snapshot()` from processing injection operators - quo <- new_quosure(substitute(expr), parent.frame()) - expect_snapshot(!!quo, cran = cran) -} - repro_profvis <- function(expr, ..., rerun = "pause", interval = 0.010) { inject(profvis({{ expr }}, ..., rerun = rerun, interval = interval)) } diff --git a/tests/testthat/test-rprof.R b/tests/testthat/test-rprof.R index f9f9ad32..8774f593 100644 --- a/tests/testthat/test-rprof.R +++ b/tests/testthat/test-rprof.R @@ -7,7 +7,7 @@ test_that("`rprof_lines()` collects profiles", { out <- rprof_lines(f(), rerun = "pause") expect_snapshot(writeLines(modal_value0(out))) - expect_snapshot0(cat_rprof(f())) + expect_snapshot(cat_rprof(f())) }) test_that("`filter.callframes` filters out intervening frames", { @@ -17,11 +17,11 @@ test_that("`filter.callframes` filters out intervening frames", { f <- function() g() g <- function() h() h <- function() pause(TEST_PAUSE_TIME) - expect_snapshot0(cat_rprof(f(), filter.callframes = TRUE)) + expect_snapshot(cat_rprof(f(), filter.callframes = TRUE)) # Intervening frames are discarded f <- function() identity(identity(pause(TEST_PAUSE_TIME))) - expect_snapshot0(cat_rprof(f(), filter.callframes = TRUE)) + expect_snapshot(cat_rprof(f(), filter.callframes = TRUE)) }) test_that("stack is correctly stripped even with metadata profiling", {