You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Conversion of POSIXct to IDate and ITime is likely to be bottleneck. I see some place for improvement to handle POSIXct directly, not using POSIXlt as it is now.
Below some timings
install.packages("microbenchmarkCore", repos= paste0("https://",c(
"olafmersmann.github.io/drat"
)))
library(microbenchmarkCore)
library(data.table)
x= as.POSIXct(1:1e7, origin="1970-01-01")
str(x)
# POSIXct[1:10000000], format: "1970-01-01 00:00:01" "1970-01-01 00:00:02" "1970-01-01 00:00:03" "1970-01-01 00:00:04" "1970-01-01 00:00:05" "1970-01-01 00:00:06" ...as.ITimeNew=function(x){
structure(as.integer(x) %%86400, class="ITime")
}
system.nanotime(
r_current<- as.ITime(x)
)
# user system elapsed # NA NA 0.7089193
system.nanotime(
r_new<- as.ITimeNew(x)
)
# user system elapsed # NA NA 0.2976062
all.equal(r_current, r_new)
# [1] TRUE
microbenchmark(times=5L,
as.ITime(x),
as.ITimeNew(x))
# Unit: milliseconds# expr min lq mean median uq max neval# as.ITime(x) 705.9513 719.4441 719.6274 723.1317 724.5856 725.0242 5# as.ITimeNew(x) 293.5473 293.6914 306.8225 300.4021 313.9687 332.5033 5
The text was updated successfully, but these errors were encountered:
jangorecki
changed the title
speed up IDateTime
speed up conversion to IDateTime
Oct 12, 2015
Conversion of POSIXct to IDate and ITime is likely to be bottleneck. I see some place for improvement to handle POSIXct directly, not using POSIXlt as it is now.
Below some timings
The text was updated successfully, but these errors were encountered: