Skip to content

Avoid splicing eagerly in bench::mark()#86

Merged
jimhester merged 4 commits intomasterfrom
fix-splicing
Jun 16, 2020
Merged

Avoid splicing eagerly in bench::mark()#86
jimhester merged 4 commits intomasterfrom
fix-splicing

Conversation

@lionel-
Copy link
Copy Markdown
Member

@lionel- lionel- commented Jun 16, 2020

Splicing too early with enexprs() transforms the spliced input into a pairlist, which has performance implications when interfacing with list2():

x <- as.list(1:1e5)
foo <- function(x) list2(!!!x)

bench::mark(
  lang = list2(!!!x),
  value = foo(x)
)[1:8]
#> # A tibble: 2 x 8
#>   expression      min   median `itr/sec` mem_alloc `gc/sec` n_itr  n_gc
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl> <int> <dbl>
#> 1 lang         41.8ms  44.73ms      21.7     781KB     2.17    10     1
#> 2 value        1.58ms   1.79ms     560.      781KB     8.74   256     4

The first commit also fixes a deprecation warning from as_tibble().

Should we also fix it in workout()? It looks like enquo() was used from the beginning so I'm not sure how much of a breaking change this would be.

@jimhester
Copy link
Copy Markdown
Member

Yeah I think we should fix it in workout as well, I think any splicing there is likely to be unintended, as romain ran into.

@lionel-
Copy link
Copy Markdown
Member Author

lionel- commented Jun 16, 2020

Now fixed in workout() as well.

@jimhester
Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants