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

audit uses of tibble() and as_tibble() #637

Merged
merged 2 commits into from
Mar 13, 2023
Merged

audit uses of tibble() and as_tibble() #637

merged 2 commits into from
Mar 13, 2023

Conversation

simonpcouch
Copy link
Contributor

Makes sure we only use tibble::tibble() and tibble::as_tibble() when we need to, as:

library(tibble)
  
tbl <- tibble()

bench::mark(
  tibble = tibble(),
  as_tibble = as_tibble(tbl),
  new_tibble_tbl = new_tibble(tbl),
  new_tibble_list = new_tibble(list()),
  iterations = 10
)
#> # A tibble: 4 × 6
#>   expression           min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>      <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 tibble            43.3µs  45.22µs    18938.      280B        0
#> 2 as_tibble        36.24µs   37.7µs    24980.     101KB        0
#> 3 new_tibble_tbl    4.88µs   5.37µs   174965.        0B        0
#> 4 new_tibble_list   4.76µs   5.43µs   184495.        0B        0

Created on 2023-03-12 with reprex v2.0.2

With main dev tune:

library(tidymodels)

bench::mark(
  fit =  fit_resamples(linear_reg(), mpg ~ ., bootstraps(mtcars)),
  iterations = 5
)
#> Warning: Some expressions had a GC in every iteration; so filtering is
#> disabled.
#> # A tibble: 1 × 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 fit           1.08s    1.09s     0.923      27MB     7.38

With this PR:

#> # A tibble: 1 × 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 fit           1.04s    1.05s     0.943      27MB     7.54

Created on 2023-03-12 with reprex v2.0.2

Copy link
Member

@hfrick hfrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏎️

R/logging.R Show resolved Hide resolved
R/merge.R Outdated Show resolved Hide resolved
R/merge.R Outdated Show resolved Hide resolved
@simonpcouch simonpcouch merged commit 94bedac into main Mar 13, 2023
@simonpcouch simonpcouch deleted the tibble-audit branch March 13, 2023 19:49
@github-actions
Copy link

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants