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

[dims] code cleanup #1068

Merged
merged 2 commits into from
Jun 29, 2024
Merged

[dims] code cleanup #1068

merged 2 commits into from
Jun 29, 2024

Conversation

JanMarvin
Copy link
Owner

@JanMarvin JanMarvin commented Jun 29, 2024

library(openxlsx2)

n <- 5e5

data1 <- data.frame(
  T1 = rep("test", n),
  T2 = rep("test", n),
  T3 = rep(as.POSIXct("2024-01-01"), n),
  T4 = rep(as.POSIXct("2024-01-01"), n)
)

data2 <- data.frame(
  T1 = rep("test", n),
  T3 = rep(as.POSIXct("2024-01-01"), n),
  T2 = rep("test", n),
  T4 = rep(as.POSIXct("2024-01-01"), n)
)

fun <- function(x) {
  wb_workbook()$
    add_worksheet(
      sheet = "test",
      grid_lines = FALSE
    )$
    add_data(
      sheet = "test",
      x = x,
      na.strings = ""
    )
}

res <- microbenchmark::microbenchmark(
  fun(data1)
  ,
  fun(data2)
  ,
  times = 5
)
#> Warning in microbenchmark::microbenchmark(fun(data1), fun(data2), times = 5):
#> less accurate nanosecond times to avoid potential integer overflows
res
#> Unit: seconds
#>        expr      min       lq     mean   median       uq      max neval
#>  fun(data1) 3.862173 3.958761 4.018850 4.018531 4.088205 4.166579     5
#>  fun(data2) 4.180478 4.184563 4.464448 4.250347 4.312143 5.394709     5

This is the performance without this PR:

res
#> Unit: seconds
#>        expr      min       lq     mean   median       uq      max neval
#>  fun(data1) 3.929952 3.942532 4.212159 3.986681 4.006506 5.195121     5
#>  fun(data2) 5.501840 5.585661 5.651573 5.624333 5.699867 5.846163     5

@JanMarvin JanMarvin merged commit 7c94ede into main Jun 29, 2024
9 checks passed
@JanMarvin JanMarvin deleted the gh_issue_1066_pt2 branch June 29, 2024 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant