For datetimes fasttime provides very fast parsing to POSIXct
library('fasttime')
library('lubridate')
library('microbenchmark')
# parse character to POSIXct
Sys.setenv(TZ='UTC')
test <- rep('2011-04-02 11:01:00',1e4)
microbenchmark(
test1 <- fastPOSIXct(test),
test2 <- fast_strptime(test,format='%Y-%m-%d %H:%M:%S'),
test3 <- as.POSIXct(test, format='%Y-%m-%d %H:%M:%S'),
test4 <- ymd_hms(test),
times=100)
Unit: microseconds
expr min lq mean median uq max
test1 <- fastPOSIXct(test) 663.123 692.337 1409.448 701.821 712.4965 71231.585
test2 <- fast_strptime(test, format = "%Y-%m-%d %H:%M:%S") 1026.342 1257.508 1263.157 1264.928 1273.8145 1366.438
test3 <- as.POSIXct(test, format = "%Y-%m-%d %H:%M:%S") 9865.265 10060.450 10154.651 10145.551 10186.3030 13358.136
test4 <- ymd_hms(test) 13990.206 17152.779 17278.654 17308.347 17393.6625 22193.544
Is there something equivalent for dates Date
, the lubridate package provides some parser but the fast one (fast_strptime) cast dates to POSIXct (not meant for dates)
Casting POSIXct to Date is too long.
Given how quick it is to parse to POSIXct I would think there should be something as quick to Date
Is there a fast packaged alternative ?