Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: atime
Type: Package
Title: Asymptotic Timing
Version: 2026.4.2
Version: 2026.4.5
Depends: R (>= 3.5.0)
Authors@R: c(
person("Toby", "Hocking",
Expand Down
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Changes in version 2026.4.5

- atime() gains check arg (default FALSE), passed to bench::mark().

Changes in version 2026.4.2

- atime_pkg() now sorts tests in facet plots to emphasize speedups, in addition to slowdowns. New pred.Nx used instead of N.factor (issue109 data and fix), as well as alternative="two.sided" instead of "greater" in t.test().
Expand Down
14 changes: 7 additions & 7 deletions R/atime.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ get_result_rows <- function(result.list){
}
}

run_bench_mark <- function(times, sub.elist, N.env, result){
m.list <- list(quote(bench::mark), iterations=times, check=FALSE)
run_bench_mark <- function(times, sub.elist, N.env, result, check){
m.list <- list(quote(bench::mark), iterations=times, check=check)
N.env$result.list <- list()
for(expr.name in names(sub.elist)){
expr <- sub.elist[[expr.name]]
Expand All @@ -36,9 +36,9 @@ run_bench_mark <- function(times, sub.elist, N.env, result){
}
m.call <- as.call(m.list)
N.df <- suppressWarnings(eval(m.call, N.env))
if(result$keep){
N.df$result <- N.env$result.list
}
N.df$result <- if(result$keep){
N.env$result.list
}else list(NULL)
N.df
}

Expand Down Expand Up @@ -74,7 +74,7 @@ check_atime_inputs <- function(N, result, elist){
list(keep=keep, fun=fun)
}

atime <- function(N=default_N(), setup, expr.list=NULL, times=10, seconds.limit=0.01, verbose=FALSE, result=FALSE, N.env.parent=NULL, ...){
atime <- function(N=default_N(), setup, expr.list=NULL, times=10, seconds.limit=0.01, verbose=FALSE, result=FALSE, N.env.parent=NULL, check=FALSE, ...){
kilobytes <- mem_alloc <- . <- sizes <- expr.name <- NULL
## above for CRAN NOTE.
formal.names <- names(formals())
Expand All @@ -96,7 +96,7 @@ atime <- function(N=default_N(), setup, expr.list=NULL, times=10, seconds.limit=
N.env <- new.env(parent=N.env.parent)
N.env$N <- N.value
eval(mc.args$setup, N.env)
N.df <- run_bench_mark(times, elist[not.done.yet], N.env, result)
N.df <- run_bench_mark(times, elist[not.done.yet], N.env, result, check)
result.row.list <- get_result_rows(N.env$result.list)
N.stats <- data.table(
N=N.value, expr.name=not.done.yet, N.df
Expand Down
6 changes: 4 additions & 2 deletions man/atime.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

\usage{atime(
N, setup, expr.list=NULL, times=10, seconds.limit=0.01, verbose=FALSE,
result=FALSE, N.env.parent=NULL, ...)}
result=FALSE, N.env.parent=NULL, check=FALSE, ...)}

\arguments{
\item{N}{numeric vector of at least two unique data sizes, default is \code{2^seq(2,20)}.}
Expand All @@ -25,7 +25,9 @@
and seconds).
}
\item{N.env.parent}{environment to use as parent of environment
created for each data size N, or NULL to use default parent env.}
created for each data size N, or NULL to use default parent env.}
\item{check}{logical, error if results are not all equal? (default
FALSE) Passed to \code{\link[bench]{mark}}.}
\item{\dots}{named expressions to time.}
}

Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-CRAN.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ test_that("more units defined in 1 row result", {
expect_identical(names(unit.tab), c("match.len","seconds"))
})

test_that("result=FALSE and check=TRUE", {
expr.list <- atime::atime_grid(seq=seq(1,N), colon=1:N)
alist <- atime::atime(expr.list=expr.list, foo=1)
alist$measurements[, expect_identical(result, replicate(.N, NULL))]
expect_error({
atime::atime(expr.list=expr.list, foo=1, check=TRUE)
}, "`seq` does not equal `foo`", fixed=TRUE)
alist <- atime::atime(expr.list=expr.list, check=TRUE)
alist$measurements[, expect_identical(result, replicate(.N, NULL))]
})

test_that("result returned when some are NULL and others not", {
atime.list <- atime::atime(
N=10^seq(-3, 0),
Expand Down
Loading