Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicit integers in filter_by_quadkey #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dshkol
Copy link

@dshkol dshkol commented Dec 30, 2020

The function filter_by_quadkey is quite slow right now. Because of the number of looping conversions, any tiny overhead that can be reduced will improve overall performance. In this case, explicitly defining integers as such reduces overhead slightly within each loop. In my tests, this leads to about a 5-10% improvement in time required for the filtering function to work.

oot <- get_performance_tiles(service = "mobile", year = 2020, quarter = 1, col_select = c("quadkey", "avg_d_kbps"))
nc <- sf::st_read(system.file("gpkg/nc.gpkg", package="sf"), quiet = TRUE)
snc <- nc[1,]

> identical(filter_by_quadkey(oot, bbox = sf::st_bbox(snc)),
+           filter_by_quadkey2(oot, bbox = sf::st_bbox(snc)))
[1] TRUE

> microbenchmark(
+   filter_by_quadkey(oot, bbox = sf::st_bbox(snc)),
+   filter_by_quadkey2(oot, bbox = sf::st_bbox(snc)),
+   times = 100
+ )
Unit: seconds
                                             expr      min       lq     mean   median       uq      max neval
  filter_by_quadkey(oot, bbox = sf::st_bbox(snc)) 5.320194 6.301838 6.648411 6.600577 7.102319 7.944158   100
 filter_by_quadkey2(oot, bbox = sf::st_bbox(snc)) 5.065415 6.160938 6.390975 6.385587 6.867021 7.405329   100

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant