hongyuanjia/eplusr

Consider to use stringi for date time manipulation

hongyuanjia opened this issue · 1 comments

{stringi} has builtin date-time manipulation functions since 0.5-2 (2015-06-21). Consider to use {stringi} for all date-time manipulation.

{lubridate} is still much faster than date-time functions in {stringi}. No reason to change now.

m <- rep(1:12, each = 10)
d <- sample(1:20, 120, TRUE)

bench::mark(
    lubridate = lubridate::make_date(2016L, month = m, day = d),
    stringi = as.Date(stringi::stri_datetime_create(2016L, month = m, day = d, hour = 0L, locale = "C", tz = "UTC"))
)
#> # A tibble: 2 × 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 lubridate     4.7µs    5.1µs   171896.       7MB    51.6 
#> 2 stringi      16.9µs   17.8µs    53111.     450KB     5.31