Here are benchmark results comparing C++ functions before and after the work in the branch albansagouis/cpp-optimisation and proposed in pull request #44 .
Essentially, changes focused on decreasing the use of Rcpp objects, passing objects by reference in C++ code and enforcing the use of const everywhere where needed.
In next steps with @mpadge, we will replace Rcpp by cpp11.
remotes::install_github(
repo = "albansagouis/parzer@2f8ede4c909929aacc491c1d7e9d63e94c7e5312",
force = TRUE)
microbenchmark::microbenchmark(
times = 400L, setup = {x <- rep("45N54.2356", 10^4)},
new = parzer:::pz_parse_lat(x),
old = parzer:::pz_parse_lat_old(x)
)
# Unit: milliseconds
# expr min lq mean median uq max neval
# new 62.51737 62.88236 63.24100 63.11897 63.31802 66.57281 400
# old 67.82839 68.30346 69.14159 68.58070 69.06854 126.01239 400
microbenchmark::microbenchmark(
times = 400L, setup = {x <- rep("45W54.2356", 10^4)},
new = parzer:::pz_parse_lon(x),
old = parzer:::pz_parse_lon_old(x)
)
# Unit: milliseconds
# expr min lq mean median uq max neval
# new 85.20321 85.60142 86.03875 85.79102 86.19459 91.38638 400
# old 90.85698 91.43344 92.06365 91.69679 92.14688 97.74293 400
microbenchmark::microbenchmark(
times = 10^6, setup = {x <- 45.235687},
new = parzer:::split_decimal_degree(x),
old = parzer:::split_decimal_degree_old(x)
)
# Unit: microseconds
# expr min lq mean median uq max neval
# new 4.920 5.207 5.949933 5.371 5.535 62011.52 1e+06
# old 5.494 5.822 6.519910 5.986 6.150 12322.26 1e+06
Session Info
```r
> devtools::session_info("loaded")
─ Session info ─────────────────────────────────────────────────────────────────
setting value
version R version 4.2.1 (2022-06-23)
os macOS Ventura 13.0.1
system aarch64, darwin20
ui RStudio
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz Europe/Berlin
date 2022-12-09
rstudio 2022.07.2+576 Spotted Wakerobin (desktop)
pandoc NA
```
Here are benchmark results comparing C++ functions before and after the work in the branch
albansagouis/cpp-optimisation
and proposed in pull request #44 .Essentially, changes focused on decreasing the use of Rcpp objects, passing objects by reference in C++ code and enforcing the use of
const
everywhere where needed.In next steps with @mpadge, we will replace
Rcpp
bycpp11
.Session Info
```r > devtools::session_info("loaded") ─ Session info ───────────────────────────────────────────────────────────────── setting value version R version 4.2.1 (2022-06-23) os macOS Ventura 13.0.1 system aarch64, darwin20 ui RStudio language (EN) collate en_US.UTF-8 ctype en_US.UTF-8 tz Europe/Berlin date 2022-12-09 rstudio 2022.07.2+576 Spotted Wakerobin (desktop) pandoc NA ```