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

Benchmarks: tidy Parameter #23

Closed
andrewallenbruce opened this issue Oct 19, 2023 · 1 comment
Closed

Benchmarks: tidy Parameter #23

andrewallenbruce opened this issue Oct 19, 2023 · 1 comment
Assignees
Labels
performance 🚀 benchmarking, profiling

Comments

@andrewallenbruce
Copy link
Owner

affiliations()

library(bench)
library(provider)
library(ggplot2)

res <- bench::mark(
  affiliations_tidy = affiliations(parent_ccn = 670055),
  affiliations_raw = affiliations(parent_ccn = 670055, tidy = FALSE, na.rm = FALSE),
  check = FALSE,
  iterations = 5)

res |> dplyr::select(expression:mem_alloc, n_itr)
#> # A tibble: 2 × 5
#>   expression             min   median `itr/sec` mem_alloc
#>   <bch:expr>        <bch:tm> <bch:tm>     <dbl> <bch:byt>
#> 1 affiliations_tidy    287ms    308ms      3.16    17.7MB
#> 2 affiliations_raw     190ms    255ms      3.88   115.6KB

res |> autoplot("ridge")

Created on 2023-10-18 with reprex v2.0.2

@andrewallenbruce andrewallenbruce self-assigned this Oct 19, 2023
@andrewallenbruce andrewallenbruce added the performance 🚀 benchmarking, profiling label Oct 24, 2023
@andrewallenbruce andrewallenbruce changed the title Benchmarking: tidy parameter Benchmarks: tidy Parameter Oct 25, 2023
@andrewallenbruce
Copy link
Owner Author

Functions with a xxxx_years() helper

One call consists of a request/response pair to the API:

  1. utils_years(): check if the year being requested is available
  2. httr2: return the data

Mapping with purrr adds another(!) req/res pair to utils_years() for each year in the iteration.

Two identical calls within 10 secs (to account for any http caching), returning a data.frame with 3,125 rows and 73 columns:

library(provider)
library(tictoc)

tic()
map_dfr(util_years(), ~utilization(year = .x, city = "Valdosta", state = "GA", type = "provider", tidy = FALSE))
toc()

#> 14.41 sec elapsed
#> 8.81 sec elapsed

5.6 second difference [~40% reduction]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance 🚀 benchmarking, profiling
Projects
None yet
Development

No branches or pull requests

1 participant