New Upstream Snapshot - r-cran-profmem

Ready changes

Summary

Merged new upstream version: 0.6.0+git20211018.1.f908c59+dfsg (was: 0.6.0+dfsg).

Resulting package

Built on 2022-10-23T23:50 (took 8m28s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-snapshots r-cran-profmem

Diff

diff --git a/DESCRIPTION b/DESCRIPTION
index 202e5d2..1ff0570 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,5 +1,5 @@
 Package: profmem
-Version: 0.6.0
+Version: 0.6.0-9001
 Title: Simple Memory Profiling for R
 Imports: utils
 Suggests: R.rsp, markdown, microbenchmark
@@ -11,10 +11,9 @@ License: LGPL (>= 2.1)
 LazyLoad: TRUE
 URL: https://github.com/HenrikBengtsson/profmem
 BugReports: https://github.com/HenrikBengtsson/profmem/issues
-RoxygenNote: 7.1.1
+RoxygenNote: 7.1.2
+Roxygen: list(markdown = TRUE)
 NeedsCompilation: no
-Packaged: 2020-12-13 20:18:56 UTC; hb
+Packaged: 2022-10-23 23:44:44 UTC; root
 Author: Henrik Bengtsson [aut, cre, cph]
 Maintainer: Henrik Bengtsson <henrikb@braju.com>
-Repository: CRAN
-Date/Publication: 2020-12-13 20:40:02 UTC
diff --git a/MD5 b/MD5
deleted file mode 100644
index 2461aec..0000000
--- a/MD5
+++ /dev/null
@@ -1,24 +0,0 @@
-12f8d8aa5116c0101cf0af9d74fc67ec *DESCRIPTION
-8b6ed37418c97388d610169f8716f878 *NAMESPACE
-0217a2d552fc8cd3a1b96ee5c1787e0a *NEWS
-a10afdfcfdc3cdb9e8dbc1ea69b4ab0c *R/Rprofmem-class.R
-7664fb8ccc1a726267368dd7b892fac3 *R/capableOfProfmem.R
-834680b6075d10d26a84a0f2e5bbb97b *R/profmem.R
-78ef25f5cc48317f3aa655e572416821 *R/readRprofmem.R
-caa2b3cdfb22a9b7129a72db6d0ce982 *R/utils.R
-8a3cf8068c00c018c05fdcfa0c75d1ac *build/vignette.rds
-9ba803f74b51e5c529076c8330c91d10 *inst/WORDLIST
-ac91707314b3c94e89762e162a934a83 *inst/doc/profmem.html
-f2d9167b3436aa9b5c1008148fba6631 *inst/doc/profmem.md.rsp
-6a2f666ad42249592a89a3bd6e2605d7 *inst/extdata/broken.Rprofmem.out
-267737f0f97a758470b5b61d256d6805 *inst/extdata/example.Rprofmem.out
-8e6ff35c959322ee0564d04738ed93c9 *man/profmem.Rd
-84a2a04798b802d7047e72c746b442a3 *man/readRprofmem.Rd
-2a36a68acf68edee59dc590fbd6fa1e8 *man/total.Rd
-c3a1565d67a7a21ba5a5668ac755036f *tests/capableOfProfmem.R
-6d6632a557fa97e603f16ff0e185c1b0 *tests/exceptions.R
-725e4a3e0a5d4c315c407d8ca59f1ab6 *tests/profmem,error.R
-2f022fe947ee2b6e19e9beb10e5b3ae5 *tests/profmem,nested.R
-f7872273570bafdf1742a503ba34fe56 *tests/profmem.R
-e74533a4715f68087d0d1498607fdd8b *tests/readRprofmem.R
-f2d9167b3436aa9b5c1008148fba6631 *vignettes/profmem.md.rsp
diff --git a/NEWS b/NEWS
index ab69b0b..f4c7255 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,18 @@
 Package: profmem
 ================
 
+Version: 0.6.0-9001 [2021-10-18]
+
+NEW FEATURES:
+
+ * profmem() gained argument 'on_error' to control what should happen when
+   there is a run-time error during profiling.  Known actions are "error",
+   "warning", and "ignore" (default).
+
+ * print() for Rprofmem objects now report on any run-time errors that
+   occurred while profiling the R expression.
+ 
+
 Version: 0.6.0 [2020-12-13]
 
 NEW FEATURES:
diff --git a/R/Rprofmem-class.R b/R/Rprofmem-class.R
index c458157..78591dd 100644
--- a/R/Rprofmem-class.R
+++ b/R/Rprofmem-class.R
@@ -121,6 +121,12 @@ print.Rprofmem <- function(x, expr = getOption("profmem.print.expr", TRUE), newp
   rownames(data)[n+1] <- "total"
 
   print(data, ...)
-  
+
+  ## Any errors to report on?
+  error <- attr(x, "error")
+  if (!is.null(error)) {
+    cat(sprintf("\nNote, an error occurred while evaluating the expression: %s\n", conditionMessage(error)))
+  }
+
   invisible(x)
 } ## print()
diff --git a/R/profmem.R b/R/profmem.R
index 6f34e1f..2687896 100644
--- a/R/profmem.R
+++ b/R/profmem.R
@@ -10,6 +10,10 @@
 #' 
 #' @param threshold The smallest memory allocation (in bytes) to log.
 #'
+#' @param on_error (character) Controls whether evaluation errors should
+#' signal an error (`"error"`), a warning (`"warning"), or be ignored
+#' (`"ignore"`; default).
+#'
 #' @return `profmem()` and `profmem_end()` returns the collected allocation
 #' data as an `Rprofmem` data.frame with additional attributes set.
 #' An `Rprofmem` data.frame has columns `what`, `bytes`, and `trace`, with:
@@ -67,11 +71,12 @@
 #'
 #' @export
 #' @importFrom utils Rprofmem
-profmem <- function(expr, envir = parent.frame(), substitute = TRUE, threshold = getOption("profmem.threshold", 0L)) {
+profmem <- function(expr, envir = parent.frame(), substitute = TRUE, threshold = getOption("profmem.threshold", 0L), on_error = c("ignore", "warning", "error")) {
   if (substitute) expr <- substitute(expr)
+  on_error <- match.arg(on_error, choices = c("ignore", "warning", "error"))
 
   profmem_begin(threshold = threshold)
-  
+
   ## Profile memory
   error <- NULL
   value <- tryCatch({
@@ -83,6 +88,12 @@ profmem <- function(expr, envir = parent.frame(), substitute = TRUE, threshold =
 
   pm <-  profmem_end()
 
+  if (on_error != "ignore") {
+    action <- switch(on_error, error = stop, warning = warning)
+    action(paste("profmem::profmem() detected a run-time error:",
+           conditionMessage(error)))
+  }
+
   ## Annotate
   attr(pm, "expression") <- expr
   attr(pm, "value") <- value
diff --git a/build/vignette.rds b/build/vignette.rds
index d231e75..a4564ff 100644
Binary files a/build/vignette.rds and b/build/vignette.rds differ
diff --git a/debian/changelog b/debian/changelog
index 9a47860..f7a4d51 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+r-cran-profmem (0.6.0+git20211018.1.f908c59+dfsg-1) UNRELEASED; urgency=low
+
+  * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Sun, 23 Oct 2022 23:44:47 -0000
+
 r-cran-profmem (0.6.0+dfsg-1) unstable; urgency=medium
 
   * New upstream version
diff --git a/inst/WORDLIST b/inst/WORDLIST
index 7dd274f..8548af6 100644
--- a/inst/WORDLIST
+++ b/inst/WORDLIST
@@ -19,6 +19,7 @@ github
 HenrikBengtsson
 https
 mc
+md
 na
 ncol
 newpage
diff --git a/man/profmem.Rd b/man/profmem.Rd
index 2c673c4..6ffd6dd 100644
--- a/man/profmem.Rd
+++ b/man/profmem.Rd
@@ -14,7 +14,8 @@ profmem(
   expr,
   envir = parent.frame(),
   substitute = TRUE,
-  threshold = getOption("profmem.threshold", 0L)
+  threshold = getOption("profmem.threshold", 0L),
+  on_error = c("ignore", "warning", "error")
 )
 
 profmem_begin(threshold = getOption("profmem.threshold", 0L))
@@ -37,6 +38,9 @@ profmem_depth()
 \item{substitute}{Should \code{expr} be \code{\link[base:substitute]{base::substitute()}}:d or not.}
 
 \item{threshold}{The smallest memory allocation (in bytes) to log.}
+
+\item{on_error}{(character) Controls whether evaluation errors should
+signal an error (\code{"error"}), a warning (\verb{"warning"), or be ignored (}"ignore"`; default).}
 }
 \value{
 \code{profmem()} and \code{profmem_end()} returns the collected allocation
diff --git a/tests/profmem,error.R b/tests/profmem,error.R
index 84eadac..a5ec26e 100644
--- a/tests/profmem,error.R
+++ b/tests/profmem,error.R
@@ -2,10 +2,27 @@ library("profmem")
 
 if (capabilities("profmem")) {
 
+## Defaults to on_error = "ignore")
 p <- profmem({
   x <- raw(1000)
   stop("Woops!")
 })
 print(p)
 
+
+for (on_error in c("ignore", "warning", "error")) {
+  message(sprintf("- profmem(..., on_error = \"%s\")", on_error))
+  res <- tryCatch({
+    profmem({
+      x <- raw(1000)
+      stop("Woops!")
+    }, on_error = on_error)
+  }, error = identity, warning = identity)
+  if (on_error == "ignore") {
+    stopifnot(inherits(res, "Rprofmem"))
+  } else {
+    stopifnot(inherits(res,  on_error))
+  }
+}
+
 } ## if (capabilities("profmem"))

Debdiff

[The following lists of changes regard files as different if they have different names, permissions or owners.]

Files in second set of .debs but not in first

-rw-r--r--  root/root   /usr/lib/R/site-library/profmem/doc/profmem.html

Control files: lines which differ (wdiff format)

  • Depends: r-base-core (>= 4.1.3.20220413-2~jan+lint1), 4.2.1-3), r-api-4.0

More details

Full run details