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

optimise cpp code #862

Merged
merged 4 commits into from
Dec 31, 2024
Merged

optimise cpp code #862

merged 4 commits into from
Dec 31, 2024

Conversation

DyfanJones
Copy link
Member

After playing around with github copilot I have managed to do some micro performance enhancements

url <- "foo = bar + 5"

(bm <- bench::mark(
  curl = curl::curl_escape(url),
  current_paws = paws.common:::paws_url_encoder(url),
  new_paws = paws_url_encoder_v2(url),
  relative = T
))
#> # A tibble: 3 × 6
#>   expression     min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl>  <dbl>     <dbl>     <dbl>    <dbl>
#> 1 curl          2.38   2.11      3.06       Inf      NaN
#> 2 current_paws  7.19   6.68      1          Inf      Inf
#> 3 new_paws      1      1         3.69       NaN      NaN

bm |> ggplot2::autoplot()
#> Loading required namespace: tidyr

Created on 2024-12-31 with reprex v2.1.1

The latest url encoder is now ~x6 faster than original.

@DyfanJones
Copy link
Member Author

Similar to uuid_v4 generator.

n <- 1

(bm <- bench::mark(
  uuid = uuid::UUIDgenerate(n),
  uwu = uwu::new_v4(n),
  current_paws = paws.common:::uuid_v4(n),
  new_paws = uuid_v4(n),
  check = F,
  relative = T
))
#> # A tibble: 4 × 6
#>   expression     min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl>  <dbl>     <dbl>     <dbl>    <dbl>
#> 1 uuid         33.2   27.3       1          Inf      Inf
#> 2 uwu           1      1.16     21.3        Inf      NaN
#> 3 current_paws  3.71   3.16      8.53       Inf      NaN
#> 4 new_paws      1.07   1        15.0        NaN      Inf

bm |> ggplot2::autoplot()
#> Loading required namespace: tidyr

Created on 2024-12-31 with reprex v2.1.1

@DyfanJones DyfanJones added the performance 🚀 Performance 🚀 label Dec 31, 2024
@DyfanJones DyfanJones merged commit 8e23e51 into paws-r:main Dec 31, 2024
5 checks passed
@DyfanJones DyfanJones added this to the Paws 0.8.0 cran release milestone Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance 🚀 Performance 🚀
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant