Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upoptimise factors_as_string #59
Comments
|
may have a solution N <- 2e4
data <- data.frame(
longitude = runif(N, -180, 180),
latitude = runif(N, -180, 180),
tooltip = sample(LETTERS, N, replace = TRUE)
, stringsAsFactors = F
)
js_fac <- jsonify::to_json(data, factors_as_string = TRUE )
microbenchmark::microbenchmark(
fact = {
data$tooltip <- as.factor( data$tooltip )
js_str <- jsonify::to_json(data, factors_as_string = FALSE )
},
str = {
data$tooltip <- as.factor( data$tooltip )
js_fac <- jsonify::to_json(data, factors_as_string = TRUE )
},
times = 5
)
# Unit: milliseconds
# expr min lq mean median uq max neval
# fact 72.17386 77.94805 81.27065 78.44088 82.10928 95.68116 5
# str 55.44182 81.18584 90.39643 85.23738 88.08029 142.03680 5 |
|
test speed for vectors & lists too. |
related: SymbolixAU/mapdeck#235