nathaneastwood / poorman

A poor man's dependency free grammar of data manipulation
https://nathaneastwood.github.io/poorman/
Other
340 stars 15 forks source link

refactor: Clean pull implementation #46

Closed markfairbanks closed 4 years ago

markfairbanks commented 4 years ago

Slightly cleaner pull() implementation. It's a bit faster too (not that this matters much, it's a pretty light function either way).

data_size <- 100000
test_df <- data.frame(a = rep(1, data_size), b = rep(2, data_size), c = rep(3, data_size))

bench::mark(current = poorman::pull(test_df, -1),
            new = new_pull(test_df, -1),
            check = TRUE, iterations = 50)
#> # A tibble: 2 x 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 current      65.5µs   66.7µs    14578.     166KB       0 
#> 2 new          16.7µs   17.6µs    52253.        0B    1066.