optimise numeric_dates
Opened this issue · 1 comments
Deleted user commented
As per #59 , move the date conversion from data.frames out of the 'by-row' iteration and up to the top level.
Deleted user commented
Before
N <- 1e3
data <- data.frame(
longitude = runif(N, -180, 180),
latitude = runif(N, -180, 180),
tooltip = sample(LETTERS, N, replace = TRUE),
date = Sys.Date()
#date_txt = as.character(Sys.Date())
)
microbenchmark::microbenchmark(
fact = {
js_str <- jsonify::to_json(data, numeric_dates = TRUE )
},
str = {
js_fac <- jsonify::to_json(data, numeric_dates = FALSE )
},
times = 5
)
# Unit: milliseconds
# expr min lq mean median uq max neval
# fact 1.663784 1.731362 1.914341 1.802852 1.940997 2.432712 5
# str 910.115947 927.891171 942.588014 929.894447 948.521252 996.517253 5
After
N <- 1e3
data <- data.frame(
longitude = runif(N, -180, 180),
latitude = runif(N, -180, 180),
tooltip = sample(LETTERS, N, replace = TRUE),
date = Sys.Date()
#date_txt = as.character(Sys.Date())
)
microbenchmark::microbenchmark(
fact = {
js_str <- jsonify::to_json(data, numeric_dates = TRUE )
},
str = {
js_fac <- jsonify::to_json(data, numeric_dates = FALSE )
},
times = 5
)
# Unit: milliseconds
# expr min lq mean median uq max neval
# fact 1.640394 1.709926 1.755007 1.758301 1.799105 1.867309 5
# str 2.459267 2.488134 2.808100 2.490519 2.693397 3.909183 5