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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R/update_cell_loop] further speedups #276

Merged
merged 2 commits into from
Jul 17, 2022
Merged

[R/update_cell_loop] further speedups #276

merged 2 commits into from
Jul 17, 2022

Conversation

JanMarvin
Copy link
Owner

@JanMarvin JanMarvin commented Jul 16, 2022

Well, sometimes it's the little things, like writing correct c++-code.

> library(microbenchmark)
> library(openxlsx2)
> 
> # a larger data frame with strings, missings and numbers
> xlsxFile <- system.file("extdata", "readTest.xlsx", package = "openxlsx2")
> wb1 <- wb_load(xlsxFile)
> data <- wb_to_df(wb1, sheet = 3, skipEmptyRows = TRUE)
> 
> res <- microbenchmark::microbenchmark(
+   wb <- wb_workbook()$add_worksheet()$add_data(x = data),
+   wb <- wb$add_data(x = data),
+   times = 25
+ ); res
Unit: milliseconds
                                                   expr       min        lq     mean    median        uq       max neval
 wb <- wb_workbook()$add_worksheet()$add_data(x = data)  31.77736  32.08635  34.6002  32.37475  32.69734  44.95653    25
                            wb <- wb$add_data(x = data) 143.69455 145.38906 149.5828 146.44222 155.83526 161.53349    25

25s -> 145ms. I'm calling it a day. Only 4.3 times slower :)

[Edit:] previously the initial creation was part of my speed measurement 馃檲

@JanMarvin JanMarvin added this to the v0.3.0 rc2 milestone Jul 16, 2022
@JanMarvin JanMarvin linked an issue Jul 16, 2022 that may be closed by this pull request
@JanMarvin JanMarvin merged commit 3222189 into main Jul 17, 2022
@JanMarvin JanMarvin deleted the rcpp_update_cell_2 branch July 17, 2022 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

update_cell() is slow
1 participant