devtools::load_all() library(tidyverse)
if(!file.exists("routes.geojson")) { routes = pct::get_pct_routes_fast("isle-of-wight") routes = routes %>% slice(1:1000) sf::write_sf(routes, "routes.geojson", delete_dsn = TRUE) } routes = geojsonsf::geojson_sf("routes.geojson") nrow(routes)
res1 = overline_old(routes, attrib = "foot")
res2 = overline3(routes, attrib = "foot")
summary(res2) summary(res2)
res = bench::mark(time_unit = "s", check = FALSE, original = {o1 <<- overline_old(routes, attrib = "foot")}, new = {o2 <<- overline3(routes, attrib = "foot")} )
The results are as follows:
res |> dplyr::select(expression, median, mem_alloc) |> mutate(routes_per_second = nrow(routes) / median) |> knitr::kable()
routes = readRDS("/tmp/uptake_commute_fastest.Rds") r = routes |> slice(seq(10000)) names(r) system.time({ rnet = overline_old(r, attrib = c("bicycle","bicycle_go_dutch","bicycle_ebike","quietness","gradient_smooth"), fun = list(sum = sum, max = first), ncores = 1, regionalise = 1e9) }) system.time({ rnet = overline3(r, attrib = c("bicycle","bicycle_go_dutch","bicycle_ebike","quietness","gradient_smooth"), fun = list(sum = sum, max = first), ncores = 1, regionalise = 1e9) }) bench::mark(check = FALSE, iterations = 1, old = {res1 <<- overline_old(r, attrib = c("bicycle","bicycle_go_dutch","bicycle_ebike","quietness","gradient_smooth"), fun = list(sum = sum, max = first), ncores = 1, regionalise = 1e9) }, new = {res2 <<- overline3(r, attrib = c("bicycle","bicycle_go_dutch","bicycle_ebike","quietness","gradient_smooth"), fun = list(sum = sum, max = first), ncores = 1, regionalise = 1e9) } )
summary(res1) summary(res2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.