Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: relative time for each parameter with bench::press #106

Open
MatthieuStigler opened this issue Feb 9, 2021 · 1 comment
Labels
feature a feature request or enhancement

Comments

@MatthieuStigler
Copy link

Thanks for this great package!

Would it be possible that summary(., relative=TRUE) prints relative time with respect to the minimum of each parameter group when using press? If one uses different input size as below, it is clear that with larger sized, timing will be longer than smaller sizes, yet one is more interested in computing within size relative timings?

Thanks!

create_df <- function(rows, cols) {
  as.data.frame(setNames(
    replicate(cols, runif(rows, 1, 1000), simplify = FALSE),
    rep_len(c("x", letters), cols)))
}

out <- bench::press(
  rows = c(1000, 10000),
  cols = c(10),
  {
    dat <- create_df(rows, cols)
    bench::mark(
      min_time = .05,
      bracket = dat[dat$x > 500, ],
      which = dat[which(dat$x > 500), ],
      subset = subset(dat, x > 500)
    )
  }
)
#> Running with:
#>    rows  cols
#> 1  1000    10
#> 2 10000    10

summary(out, relative=TRUE)
#> # A tibble: 6 x 8
#>   expression  rows  cols   min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <dbl> <dbl> <dbl>  <dbl>     <dbl>     <dbl>    <dbl>
#> 1 bracket     1000    10  1.10   1.10      6.49      2.09      Inf
#> 2 which       1000    10  1      1         6.97      1         NaN
#> 3 subset      1000    10  1.35   1.41      5.19      2.59      Inf
#> 4 bracket    10000    10  7.22   7.39      1        21.5       Inf
#> 5 which      10000    10  3.70   2.96      2.12     10.6       Inf
#> 6 subset     10000    10  8.28   6.28      1.13     23.6       Inf

Created on 2021-02-09 by the reprex package (v1.0.0)

@DavisVaughan
Copy link
Member

DavisVaughan commented May 3, 2023

For future us: This is complicated by the fact that bench::press() returns an object with the same class as bench::mark(), so there is no way for summary.bench_mark() to understand that the relative results need to be computed within each parameter combination.

  • bench::press() could return a bench_press subclass
  • bench::press() could add on a parameters attribute that summary.bench_mark() knows to look for (but knowing when to invalidate this could be hard, like if the tibble is sliced by [).

@DavisVaughan DavisVaughan added the feature a feature request or enhancement label May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants