hrbrpkghelpr::global_opts()
hrbrpkghelpr::stinking_badges()
Tools to Test and Compare Internet Bandwidth Speeds
The 'Ookla' 'Speedtest' site https://beta.speedtest.net/about provides interactive and programmatic services to test and compare bandwidth speeds from a source node on the Internet to thousands of test servers. Tools are provided to obtain test server lists, identify target servers for testing and performing speed/bandwidth tests.
The following functions are implemented:
hrbrpkghelpr::describe_ingredients()
While you can run spd_test()
from an R console, it was desgined to be an easily wrapped into a bash
(et al) alias or put into a small batch script. Or, you can just type out the following if you're fleet-of-finger/have dexterous digits:
Rscript --quiet -e 'speedtest::spd_test()'
which will look something like:
Folks interested in contributing can take a look at the TODOs and pick as many as you like! Ones with question marks are truly a "I dunno if we shld" kinda thing. Ones with exclamation marks are essentials.
autoplot
support!hrbrpkghelpr::install_block()
library(speedtest) library(stringi) library(hrbrthemes) library(ggbeeswarm) library(tidyverse) # current verison packageVersion("speedtest")
config <- spd_config() servers <- spd_servers(config=config) closest_servers <- spd_closest_servers(servers, config=config) only_the_best_severs <- spd_best_servers(closest_servers, config)
glimpse(spd_download_test(closest_servers[1,], config=config)) glimpse(spd_download_test(only_the_best_severs[1,], config=config))
glimpse(spd_upload_test(only_the_best_severs[1,], config=config)) glimpse(spd_upload_test(closest_servers[1,], config=config))
Choose closest, "best" and randomly (there can be, and are, some dups as a result for best/closest), run the test and chart the results. This will show just how disparate the results are from these core/crude tests. Most of the test servers compensate when they present the results. Newer, "socket"-based tests are more accurate but there are no free/hidden exposed APIs yet for most of them.
set.seed(8675309) bind_rows( closest_servers[1:3,] %>% mutate(type="closest"), only_the_best_severs[1:3,] %>% mutate(type="best"), filter(servers, !(id %in% c(closest_servers[1:3,]$id, only_the_best_severs[1:3,]$id))) %>% sample_n(3) %>% mutate(type="random") ) %>% group_by(type) %>% ungroup() -> to_compare select(to_compare, sponsor, name, country, host, type) map_df(1:nrow(to_compare), ~{ spd_download_test(to_compare[.x,], config=config, summarise=FALSE, timeout=30) }) -> dl_results_full mutate(dl_results_full, type=stri_trans_totitle(type)) %>% ggplot(aes(type, bw, fill=type)) + geom_quasirandom(aes(size=size, color=type), width=0.15, shape=21, stroke=0.25) + scale_y_continuous(expand=c(0,5)) + scale_size(range=c(2,6)) + scale_color_manual(values=c(Random="#b2b2b2", Best="#2b2b2b", Closest="#2b2b2b")) + scale_fill_ipsum() + labs(x=NULL, y=NULL, title="Download bandwidth test by selected server type", subtitle="Circle size scaled by size of file used in that speed test") + theme_ipsum_rc(grid="Y") + theme(legend.position="none")
Choose closest and "best" and filter duplicates out since we're really trying to measure here vs show the disparity:
bind_rows( closest_servers[1:3,] %>% mutate(type="closest"), only_the_best_severs[1:3,] %>% mutate(type="best") ) %>% distinct(.keep_all=TRUE) -> to_compare select(to_compare, sponsor, name, country, host, type) map_df(1:nrow(to_compare), ~{ spd_upload_test(to_compare[.x,], config=config, summarise=FALSE, timeout=30) }) -> ul_results_full ggplot(ul_results_full, aes(x="Upload Test", y=bw)) + geom_quasirandom(aes(size=size, fill="col"), width=0.1, shape=21, stroke=0.25, color="#2b2b2b") + scale_y_continuous(expand=c(0,0.5)) + scale_size(range=c(2,6)) + scale_fill_ipsum() + labs(x=NULL, y=NULL, title="Upload bandwidth test by selected server type", subtitle="Circle size scaled by size of file used in that speed test") + theme_ipsum_rc(grid="Y") + theme(legend.position="none")
cloc::cloc_pkg_md()
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.