Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Slow (very slow) "Date" to "character" comparison #475

Closed
wkostelecki opened this issue Sep 22, 2016 · 1 comment
Closed

Slow (very slow) "Date" to "character" comparison #475

wkostelecki opened this issue Sep 22, 2016 · 1 comment

Comments

@wkostelecki
Copy link

Date to character comparison becomes very slow after lubridate is loaded. It looks like this became a problem somewhere between lubridate 1.5.6 and 1.6.0.

library(microbenchmark)
x = seq(as.Date("2000-01-01"), by = 1, length.out = 1e6)

microbenchmark(x < "2011-01-01", x < as.Date("2011-01-01"), times = 10)

Unit: milliseconds
                      expr      min       lq     mean   median       uq      max neval
          x < "2011-01-01" 5.399231 5.441528 5.697184 5.667326 5.841183 6.199474    10
 x < as.Date("2011-01-01") 5.327697 5.493157 5.738424 5.708690 5.990160 6.384528    10

library(lubridate)

microbenchmark(x < "2011-01-01", x < as.Date("2011-01-01"), times = 10)

Unit: milliseconds
                      expr          min          lq         mean       median           uq          max neval
          x < "2011-01-01" 19626.572302 19871.22804 20028.643821 20068.059074 20270.531927 20355.048546    10
 x < as.Date("2011-01-01")     4.124068     5.89188     5.708008     6.059362     6.124209     6.212538    10
@vspinu
Copy link
Member

vspinu commented Sep 23, 2016

Hm. That was unintentional change. I am looking into how to properly handle this.

@vspinu vspinu closed this as completed in d561bf1 Sep 23, 2016
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants