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

Use events to iterate over all pillars in the correct order #435

Merged
merged 47 commits into from
Dec 30, 2021
Merged

Conversation

krlmlr
Copy link
Member

@krlmlr krlmlr commented Dec 30, 2021

in the hierarchical structure. Each pillar object that is constructed is also shown. Allows collecting columns that could not be shown or were truncated (#365).

This PR

library(tidyverse)

books_wide <-
  janeaustenr::austen_books() %>%
  tidytext::unnest_tokens(word, text) %>%
  mutate(value = 1L) %>%
  pivot_wider(book, word, values_fn = sum, names_repair = "minimal")

books_wide
#> # A tibble: 6 × 14,521
#>   book     sense   and sensibility    by  jane austen `1811` chapter   `1`   the
#>   <fct>    <int> <int>       <int> <int> <int>  <int>  <int>   <int> <int> <int>
#> 1 Sense &…    32  3490          10   749     1      1      1      50     2  4105
#> 2 Pride &…    36  3585           2   636   264      1     NA      61     1  4331
#> 3 Mansfie…    42  5438           4   696     1      1     NA      49    NA  6206
#> 4 Emma        56  4896           6   571   282      1     NA      56    NA  5201
#> 5 Northan…    18  2306           3   475     1      1     NA      32     1  3179
#> 6 Persuas…    17  2800           4   418     1      1     NA      24     3  3329
#> # … with 14,510 more variables: family <int>, of <int>, dashwood <int>,
#> #   had <int>, long <int>, been <int>, settled <int>, `in` <int>, sussex <int>,
#> #   their <int>, estate <int>, was <int>, large <int>, residence <int>,
#> #   at <int>, norland <int>, park <int>, centre <int>, property <int>,
#> #   where <int>, `for` <int>, many <int>, generations <int>, they <int>,
#> #   lived <int>, so <int>, respectable <int>, a <int>, manner <int>, as <int>,
#> #   to <int>, engage <int>, general <int>, good <int>, opinion <int>, …

bench::mark(format(books_wide, width = 80))
#> # A tibble: 1 × 6
#>   expression                          min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>                     <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 format(books_wide, width = 80)   65.6ms   65.6ms      15.2    5.17MB     45.7
bench::mark(format(books_wide, width = 800))
#> 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 format(books_wide, width = 800)    122ms    129ms      7.85     5.2MB     13.7
bench::mark(format(books_wide, width = 8000))
#> 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:t>     <dbl> <bch:byt>    <dbl>
#> 1 format(books_wide, width = 8000)    668ms   668ms      1.50    6.95MB     15.0
bench::mark(format(books_wide, width = 80000))
#> 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:>     <dbl> <bch:byt>    <dbl>
#> 1 format(books_wide, width = 80000)    5.38s  5.38s     0.186     140MB     8.36

Created on 2021-12-30 by the reprex package (v2.0.1)

CRAN pillar

library(tidyverse)

books_wide <-
  janeaustenr::austen_books() %>%
  tidytext::unnest_tokens(word, text) %>%
  mutate(value = 1L) %>%
  pivot_wider(book, word, values_fn = sum, names_repair = "minimal")

bench::mark(format(books_wide, width = 80))
#> # A tibble: 1 × 6
#>   expression                          min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>                     <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 format(books_wide, width = 80)   61.5ms     62ms      16.0    4.66MB     26.7
bench::mark(format(books_wide, width = 800))
#> 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 format(books_wide, width = 800)    121ms    123ms      8.10    4.75MB     11.3
bench::mark(format(books_wide, width = 8000))
#> 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:t>     <dbl> <bch:byt>    <dbl>
#> 1 format(books_wide, width = 8000)    648ms   648ms      1.54     7.3MB     13.9
bench::mark(format(books_wide, width = 80000))
#> 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:>     <dbl> <bch:byt>    <dbl>
#> 1 format(books_wide, width = 80000)    5.53s  5.53s     0.181     145MB     7.23

Created on 2021-12-30 by the reprex package (v2.0.1)

@krlmlr krlmlr changed the title Use event handling to iterate over all pillars in the correct order Use events to iterate over all pillars in the correct order Dec 30, 2021
@krlmlr krlmlr merged commit a46a587 into main Dec 30, 2021
@krlmlr krlmlr deleted the f-coro-2 branch December 30, 2021 20:48
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 31, 2022
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.

1 participant