Browse Source

general cleanup

master
boB Rudis 5 years ago
parent
commit
47f1f4a0f2
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 8
      .Rbuildignore
  2. 31
      .travis.yml
  3. 61
      DESCRIPTION
  4. 2
      LICENSE
  5. 21
      LICENSE.md
  6. 7
      NAMESPACE
  7. 7
      NEWS.md
  8. 12
      R/aaa.r
  9. 3
      R/bestest.r
  10. 5
      R/config.r
  11. 11
      R/servers.r
  12. 8
      R/speedtest-package.R
  13. 12
      R/test-main.r
  14. 14
      R/upload.r
  15. 15
      R/util.r
  16. 11
      R/utils-pipe.R
  17. 66
      README.Rmd
  18. 312
      README.gfm-ascii_identifiers
  19. BIN
      README.gfm-ascii_identifiers_files/figure-gfm/unnamed-chunk-10-1.png
  20. BIN
      README.gfm-ascii_identifiers_files/figure-gfm/unnamed-chunk-11-1.png
  21. BIN
      README.gfm-ascii_identifiers_files/figure-gfm/unnamed-chunk-12-1.png
  22. BIN
      README.gfm-ascii_identifiers_files/figure-gfm/unnamed-chunk-5-1.png
  23. BIN
      README.gfm-ascii_identifiers_files/figure-gfm/unnamed-chunk-7-1.png
  24. BIN
      README.gfm-ascii_identifiers_files/figure-gfm/unnamed-chunk-9-1.png
  25. 269
      README.md
  26. 3
      README_cache/gfm/__packages
  27. BIN
      README_cache/gfm/dl-speeed_31ed0600c0555b226365c572514c60ee.RData
  28. BIN
      README_cache/gfm/dl-speeed_31ed0600c0555b226365c572514c60ee.rdb
  29. BIN
      README_cache/gfm/dl-speeed_31ed0600c0555b226365c572514c60ee.rdx
  30. BIN
      README_cache/gfm/individ-dl_d8acf06a65b57ecf7a891dff9743a153.RData
  31. 0
      README_cache/gfm/individ-dl_d8acf06a65b57ecf7a891dff9743a153.rdb
  32. BIN
      README_cache/gfm/individ-dl_d8acf06a65b57ecf7a891dff9743a153.rdx
  33. BIN
      README_cache/gfm/individ-up_bef9661be29204fe5a1fe1a9df42e3bf.RData
  34. 0
      README_cache/gfm/individ-up_bef9661be29204fe5a1fe1a9df42e3bf.rdb
  35. BIN
      README_cache/gfm/individ-up_bef9661be29204fe5a1fe1a9df42e3bf.rdx
  36. BIN
      README_cache/gfm/moar-dl-tests_21cafef69b9f6499b9aa8b2c347a598f.RData
  37. BIN
      README_cache/gfm/moar-dl-tests_21cafef69b9f6499b9aa8b2c347a598f.rdb
  38. BIN
      README_cache/gfm/moar-dl-tests_21cafef69b9f6499b9aa8b2c347a598f.rdx
  39. BIN
      README_cache/gfm/moar-ul-tests_8bc45b6683652bd85c8272cd2dabb5e1.RData
  40. BIN
      README_cache/gfm/moar-ul-tests_8bc45b6683652bd85c8272cd2dabb5e1.rdb
  41. BIN
      README_cache/gfm/moar-ul-tests_8bc45b6683652bd85c8272cd2dabb5e1.rdx
  42. BIN
      README_cache/gfm/unnamed-chunk-10_a05d32b06c329a82c57de508b8e165c1.RData
  43. 0
      README_cache/gfm/unnamed-chunk-10_a05d32b06c329a82c57de508b8e165c1.rdb
  44. BIN
      README_cache/gfm/unnamed-chunk-10_a05d32b06c329a82c57de508b8e165c1.rdx
  45. BIN
      README_cache/gfm/unnamed-chunk-11_7def8c4e0574346221b17493aa83ccd1.RData
  46. BIN
      README_cache/gfm/unnamed-chunk-11_7def8c4e0574346221b17493aa83ccd1.rdb
  47. BIN
      README_cache/gfm/unnamed-chunk-11_7def8c4e0574346221b17493aa83ccd1.rdx
  48. BIN
      README_cache/gfm/unnamed-chunk-12_c763d3cf0c31639005806c1f67aa0e19.RData
  49. 0
      README_cache/gfm/unnamed-chunk-12_c763d3cf0c31639005806c1f67aa0e19.rdb
  50. BIN
      README_cache/gfm/unnamed-chunk-12_c763d3cf0c31639005806c1f67aa0e19.rdx
  51. BIN
      README_cache/gfm/unnamed-chunk-13_ea042d41f7055d0784f2db8b8df9b01a.RData
  52. 0
      README_cache/gfm/unnamed-chunk-13_ea042d41f7055d0784f2db8b8df9b01a.rdb
  53. BIN
      README_cache/gfm/unnamed-chunk-13_ea042d41f7055d0784f2db8b8df9b01a.rdx
  54. BIN
      README_cache/gfm/unnamed-chunk-2_5b0ba01bb43aefa1232c8b724a6601e4.RData
  55. 0
      README_cache/gfm/unnamed-chunk-2_5b0ba01bb43aefa1232c8b724a6601e4.rdb
  56. BIN
      README_cache/gfm/unnamed-chunk-2_5b0ba01bb43aefa1232c8b724a6601e4.rdx
  57. BIN
      README_cache/gfm/unnamed-chunk-3_c2d6adad80c87c748cd07e4fbf805a99.RData
  58. 0
      README_cache/gfm/unnamed-chunk-3_c2d6adad80c87c748cd07e4fbf805a99.rdb
  59. BIN
      README_cache/gfm/unnamed-chunk-3_c2d6adad80c87c748cd07e4fbf805a99.rdx
  60. BIN
      README_cache/gfm/unnamed-chunk-4_bb201e0df1071cb65b54fdc9bebf413d.RData
  61. 0
      README_cache/gfm/unnamed-chunk-4_bb201e0df1071cb65b54fdc9bebf413d.rdb
  62. BIN
      README_cache/gfm/unnamed-chunk-4_bb201e0df1071cb65b54fdc9bebf413d.rdx
  63. BIN
      README_cache/gfm/unnamed-chunk-5_08af825d6f4cb3312e5f922882aff56f.RData
  64. BIN
      README_cache/gfm/unnamed-chunk-5_08af825d6f4cb3312e5f922882aff56f.rdb
  65. BIN
      README_cache/gfm/unnamed-chunk-5_08af825d6f4cb3312e5f922882aff56f.rdx
  66. BIN
      README_cache/gfm/unnamed-chunk-6_a08421919cfedfed307e2451eebc3090.RData
  67. BIN
      README_cache/gfm/unnamed-chunk-6_a08421919cfedfed307e2451eebc3090.rdx
  68. BIN
      README_cache/gfm/unnamed-chunk-7_c4f4f0b44c2fc2d6ee8870ae77830ebf.RData
  69. BIN
      README_cache/gfm/unnamed-chunk-7_c4f4f0b44c2fc2d6ee8870ae77830ebf.rdx
  70. BIN
      README_cache/gfm/unnamed-chunk-8_589608964690a85b75a2c454d204378e.RData
  71. BIN
      README_cache/gfm/unnamed-chunk-8_589608964690a85b75a2c454d204378e.rdb
  72. BIN
      README_cache/gfm/unnamed-chunk-8_589608964690a85b75a2c454d204378e.rdx
  73. BIN
      README_cache/gfm/unnamed-chunk-9_c2b4b56b83ed174d8c32859946fd3840.RData
  74. BIN
      README_cache/gfm/unnamed-chunk-9_c2b4b56b83ed174d8c32859946fd3840.rdb
  75. BIN
      README_cache/gfm/unnamed-chunk-9_c2b4b56b83ed174d8c32859946fd3840.rdx
  76. BIN
      README_files/figure-gfm/unnamed-chunk-10-1.png
  77. BIN
      README_files/figure-gfm/unnamed-chunk-11-1.png
  78. BIN
      README_files/figure-gfm/unnamed-chunk-12-1.png
  79. BIN
      README_files/figure-gfm/unnamed-chunk-9-1.png
  80. 45
      appveyor.yml
  81. 8
      inst/tinytest/test_speedtest.R
  82. BIN
      man/figures/README-moar-dl-tests-1.png
  83. BIN
      man/figures/README-moar-ul-tests-1.png
  84. 0
      man/figures/spdtst.gif
  85. 19
      man/nice_speed.Rd
  86. 12
      man/pipe.Rd
  87. 4
      man/spd_download_test.Rd
  88. 4
      man/spd_upload_test.Rd
  89. 10
      man/speedtest.Rd
  90. 2
      tests/test-all.R
  91. 12
      tests/testthat/test-speedtest.R
  92. 5
      tests/tinytest.R

8
.Rbuildignore

@ -5,8 +5,14 @@
^README\.*html$
^NOTES\.*Rmd$
^NOTES\.*html$
^README\.gfm*$
^README_cache$
^\.codecov\.yml$
^README_files$
^doc$
^CONDUCT\.md$
^imgs$
^imgs$
^LICENSE\.md$
^Makefile$
^appveyor\.yml$

31
.travis.yml

@ -1,31 +1,4 @@
language: r
warnings_are_errors: true
sudo: required
language: R
cache: packages
r:
- oldrel
- release
- devel
apt_packages:
- libv8-dev
- xclip
env:
global:
- CRAN: http://cran.rstudio.com
after_success:
- Rscript -e 'covr::codecov()'
notifications:
email:
- bob@rud.is
irc:
channels:
- "104.236.112.222#builds"
nick: travisci
- Rscript -e 'covr::codecov()'

61
DESCRIPTION

@ -1,40 +1,31 @@
Package: speedtest
Type: Package
Title: Tools to Test and Compare Internet Bandwidth Speeds
Version: 0.1.0
Date: 2017-11-09
Authors@R: c(
person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-5670-2640")),
person("Bryce", "Mecum", email = "petridish@gmail.com", role = "ctb",
comment = c(ORCID = "0000-0002-0381-3766")),
person("Garrett", "Mooney", email = "gmooney@mail.bradley.edu", role = "ctb")
)
Author: Bob Rudis (bob@rud.is)
Version: 0.2.0
Date: 2019-07-24
Authors@R: c( person("Bob", "Rudis", email = "bob@rud.is",
role = c("aut", "cre"), comment = c(ORCID =
"0000-0001-5670-2640")), person("Bryce", "Mecum",
email = "petridish@gmail.com", role = "ctb", comment
= c(ORCID = "0000-0002-0381-3766")),
person("Garrett", "Mooney", email =
"gmooney@mail.bradley.edu", role = "ctb") )
Maintainer: Bob Rudis <bob@rud.is>
Description: The 'Ookla' 'Speedtest' site <http://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.
URL: https://github.com/hrbrmstr/speedtest
BugReports: https://github.com/hrbrmstr/speedtest/issues
License: AGPL
Suggests:
testthat,
covr
Depends:
R (>= 3.2.0)
Description: The 'Ookla' 'Speedtest' site
<http://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.
URL: https://gitlab.com/hrbrmstr/speedtest
BugReports: https://gitlab.com/hrbrmstr/speedtest/issues
License: MIT + file LICENSE
Suggests: covr, tinytest
Depends: R (>= 3.2.0)
Encoding: UTF-8
Imports:
curl,
purrr,
dplyr,
xml2,
utils,
pingr,
urltools,
jsonlite,
crayon,
cli
RoxygenNote: 6.0.1
Imports: httr, stats, curl, purrr, dplyr, xml2, utils,
pingr, urltools, jsonlite, crayon, tibble, cli,
magrittr
RoxygenNote: 6.1.1

2
LICENSE

@ -0,0 +1,2 @@
YEAR: 2019
COPYRIGHT HOLDER: Bob Rudis

21
LICENSE.md

@ -0,0 +1,21 @@
# MIT License
Copyright (c) 2019 Bob Rudis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

7
NAMESPACE

@ -1,5 +1,7 @@
# Generated by roxygen2: do not edit by hand
export("%>%")
export(nice_speed)
export(spd_best_servers)
export(spd_closest_servers)
export(spd_compute_bandwidth)
@ -16,13 +18,16 @@ import(xml2)
importFrom(curl,curl_fetch_multi)
importFrom(curl,multi_run)
importFrom(dplyr,arrange)
importFrom(dplyr,data_frame)
importFrom(dplyr,filter)
importFrom(dplyr,left_join)
importFrom(dplyr,mutate)
importFrom(dplyr,select)
importFrom(dplyr,summarise)
importFrom(jsonlite,fromJSON)
importFrom(magrittr,"%>%")
importFrom(pingr,ping)
importFrom(stats,median)
importFrom(stats,sd)
importFrom(tibble,tibble)
importFrom(urltools,domain)
importFrom(utils,globalVariables)

7
NEWS.md

@ -1,2 +1,9 @@
0.2.0
* Updated pkg infrastructure (non-salient to operations)
* Now passes CRAN checks
* Updated user agent
* Ensured primary URLs for speedtest resources are HTTPS
* Swiched to {tinytest}
0.1.0
* Initial release

12
R/aaa.r

@ -1,7 +1,13 @@
.base_raw <- charToRaw('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ')
.speedtest_ua <- "Mozilla/5.0 (Compatibe; r-speedtest/1.0; https://github.com/hrbrmstr/speedtest)"
.speedtest_ua <- "Mozilla/5.0 (Compatible; r-speedtest/1.0; https://gitlab.com/hrbrmstr/speedtest)"
utils::globalVariables(
c("total", "latency_url", "test_result", "ping_time", "total_time", "retrieval_time",
"bw", "size", "secs"))
c(
"total", "latency_url", "test_result", "ping_time", "total_time",
"retrieval_time", "bw", "size", "secs", "id"
)
)
sGET <- purrr::safely(httr::GET)
sPOST <- purrr::safely(httr::POST)

3
R/bestest.r

@ -41,8 +41,9 @@ spd_best_servers <- function(servers=NULL, config=NULL, max=10) {
curl::multi_run()
purrr::map_df(.lat_dat, ~{
data_frame(
tibble(
latency_url = .x$url,
# TODO add some code to let this be a thing
# ping_time = mean(pingr::ping(urltools::domain(.x$url)), na.rm=TRUE)/1000,
total_time = .x$times["total"],
retrieval_time = .x$times[6] - .x$times[5],

5
R/config.r

@ -7,7 +7,10 @@
#' }
spd_config <- function() {
res <- httr::GET("http://www.speedtest.net/speedtest-config.php")
httr::GET(
url = "https://www.speedtest.net/speedtest-config.php",
httr::user_agent(.speedtest_ua)
) -> res
httr::stop_for_status(res)

11
R/servers.r

@ -11,15 +11,18 @@
#' }
spd_servers <- function(config=NULL) {
res <- httr::GET("https://www.speedtest.net/speedtest-servers-static.php")
httr::GET(
url = "https://www.speedtest.net/speedtest-servers-static.php",
httr::user_agent(.speedtest_ua)
) -> res
httr::stop_for_status(res)
if (is.null(config)) config <- spd_config()
httr::content(res, as="text", encoding="UTF-8") %>%
read_xml() %>%
xml2::xml_find_all(xpath="//settings/servers/server") %>%
httr::content(res, as = "text", encoding = "UTF-8") %>%
xml2::read_xml() %>%
xml2::xml_find_all(xpath = "//settings/servers/server") %>%
purrr::map_df(~{
list(
url = xml2::xml_attr(.x, "url") %||% NA_character_,

8
R/speedtest-package.R

@ -1,6 +1,6 @@
#' Tools to Test and Compare Internet Bandwidth Speeds
#'
#' The 'Ookla' 'Speedtest' site <http://beta.speedtest.net/about> provides
#' 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
@ -12,9 +12,11 @@
#' @author Bob Rudis (bob@@rud.is)
#' @import purrr xml2 httr cli crayon
#' @importFrom utils globalVariables
#' @importFrom dplyr left_join arrange filter data_frame select summarise mutate
#' @importFrom tibble tibble
#' @importFrom dplyr left_join arrange filter select summarise mutate
#' @importFrom jsonlite fromJSON
#' @importFrom curl curl_fetch_multi multi_run
#' @importFrom pingr ping
#' @importFrom urltools domain
NULL
#' @importFrom stats median sd
"_PACKAGE"

12
R/test-main.r

@ -22,15 +22,17 @@ spd_test <- function() {
cat(cyan("Determining best server...\n"))
servers <- spd_closest_servers(servers, config)
# best <- servers
# best <- servers
best <- spd_best_servers(servers, config, max=3)
cat(green("Initiating test from ") %+% white(config$client$isp) %+% green(" (") %+%
white(config$client$ip) %+% green(") to ") %+% white(best$sponsor[1]) %+%
green(" (") %+% white(best$name[1]) %+% green(")\n\n"))
cat(
green("Initiating test from ") %+% white(config$client$isp) %+% green(" (") %+%
white(config$client$ip) %+% green(") to ") %+% white(best$sponsor[1]) %+%
green(" (") %+% white(best$name[1]) %+% green(")\n\n")
)
cat(white$bold("Analyzing download speed"))
down <- spd_download_test(best, config, FALSE, timeout=5, .progress="dots")
down <- spd_download_test(best, config, FALSE, timeout = 5, .progress = "dots")
cat(green("Download: ") %+% white$bold(nice_speed(max(down$bw))) %+% "\n")

14
R/upload.r

@ -25,7 +25,8 @@
#' @note speed/bandwidth values are in Mbits/s; these tests consume bandwidth so
#' if you're on a metered connection, you may incur charges.
#' @export
spd_upload_test <- function(server, config=NULL, summarise=TRUE, timeout=60, .progress="dplyr") {
spd_upload_test <- function(server, config = NULL, summarise = TRUE, timeout=60,
.progress = "dplyr") {
if (nrow(server) > 1) server <- server[1,]
@ -55,9 +56,14 @@ spd_upload_test <- function(server, config=NULL, summarise=TRUE, timeout=60, .pr
if (.progress == 'dots') cat("\n", sep="")
if (summarise) {
out <- dplyr::summarise(out, min=min(bw, na.rm=TRUE), mean=mean(bw, na.rm=TRUE),
median=median(bw, na.rm=TRUE), max=max(bw, na.rm=TRUE),
sd=sd(bw, na.rm=TRUE))
dplyr::summarise(
out,
min = min(bw, na.rm = TRUE),
mean = mean(bw, na.rm = TRUE),
median = median(bw, na.rm = TRUE),
max = max(bw, na.rm = TRUE),
sd = sd(bw, na.rm = TRUE)
) -> out
}
out$id <- server$id

15
R/util.r

@ -1,17 +1,13 @@
sGET <- purrr::safely(httr::GET)
sPOST <- purrr::safely(httr::POST)
.download_one <- function(url, timeout) {
sGET(
url = url,
httr::add_headers(
`Referer` = "http://c.speedtest.net/flash/speedtest.swf",
`Referer` = "https://c.speedtest.net/flash/speedtest.swf",
`Cache-Control` = "no-cache" # try to bust transparent proxy caches
),
httr::user_agent(.speedtest_ua),
httr::timeout(timeout),
query=list(ts=as.numeric(Sys.time())) # try to bust transparent proxy caches
query = list(ts = as.numeric(Sys.time())) # try to bust transparent proxy caches
)
}
@ -19,15 +15,15 @@ sPOST <- purrr::safely(httr::POST)
sPOST(
url = url,
httr::add_headers(
`Referer` = "http://c.speedtest.net/flash/speedtest.swf",
`Referer` = "https://c.speedtest.net/flash/speedtest.swf",
`Connection` = "Keep-Alive",
`Cache-Control` = "no-cache" # try to bust transparent proxy caches
),
encode="form",
body=dat,
body = dat,
httr::user_agent(.speedtest_ua),
httr::timeout(timeout),
query=list(ts=as.numeric(Sys.time())) # try to bust transparent proxy caches
query = list(ts = as.numeric(Sys.time())) # try to bust transparent proxy caches
)
}
@ -38,6 +34,7 @@ sPOST <- purrr::safely(httr::POST)
#' - Only chooses between Kbit/s, Mbit/s, and Gbit/s
#'
#' @param number numeric The speed to be converted
#' @export
#' @return character The character representation of the speed
nice_speed <- function(number) {
if (number < 1) {

11
R/utils-pipe.R

@ -0,0 +1,11 @@
#' Pipe operator
#'
#' See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details.
#'
#' @name %>%
#' @rdname pipe
#' @keywords internal
#' @export
#' @importFrom magrittr %>%
#' @usage lhs \%>\% rhs
NULL

66
README.Rmd

@ -1,34 +1,32 @@
---
title: "speedtest"
output:
github_document:
html_preview: true
output: rmarkdown::github_document
editor_options:
chunk_output_type: console
---
```{r include=FALSE}
knitr::opts_chunk$set(cache=TRUE, message=FALSE, warning=FALSE, error=FALSE, fig.retina=2)
```{r pkg-knitr-opts, include=FALSE}
hrbrpkghelpr::global_opts()
```
```{r badges, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::stinking_badges()
```
# speedtest
Tools to Test and Compare Internet Bandwidth Speeds
## Description
The 'Ookla' 'Speedtest' site <http://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 'Ookla' 'Speedtest' site <http://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.
## What's Inside The Tin
The following functions are implemented:
- `spd_best_servers`: Find "best" servers (latency-wise) from master server list
- `spd_closest_servers`: Find "closest" servers (geography-wise) from master server list
- `spd_compute_bandwidth`: Compute bandwidth from bytes transferred and time taken
- `spd_config`: Retrieve client configuration information for the speedtest
- `spd_download_test`: Perform a download speed/bandwidth test
- `spd_servers`: Retrieve a list of SpeedTest servers
- `spd_upload_test`: Perform an upload speed/bandwidth test
- `spd_test`: Test your internet speed/bandwidth
```{r ingredients, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::describe_ingredients()
```
## Make a CLI utility
@ -38,7 +36,7 @@ While you can run `spd_test()` from an R console, it was desgined to be an easil
which will look something like:
![](imgs/spdtst.gif)
![](man/figures/spdtst.gif)
## TODO
@ -56,17 +54,13 @@ Folks interested in contributing can take a look at the TODOs and pick as many a
## Installation
```{r eval=FALSE}
devtools::install_github("hrbrmstr/speedtest")
```
```{r}
options(width=120)
```{r install-ex, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::install_block()
```
## Usage
```{r cache=FALSE}
```{r libs, cache=FALSE}
library(speedtest)
library(stringi)
library(hrbrthemes)
@ -79,7 +73,7 @@ packageVersion("speedtest")
### Download Speed
```{r}
```{r dl-speeed, cache=TRUE}
config <- spd_config()
servers <- spd_servers(config=config)
@ -89,7 +83,7 @@ only_the_best_severs <- spd_best_servers(closest_servers, config)
### Individual download tests
```{r}
```{r individ-dl, cache=TRUE}
glimpse(spd_download_test(closest_servers[1,], config=config))
glimpse(spd_download_test(only_the_best_severs[1,], config=config))
@ -97,7 +91,7 @@ glimpse(spd_download_test(only_the_best_severs[1,], config=config))
### Individual upload tests
```{r}
```{r individ-up, cache=TRUE}
glimpse(spd_upload_test(only_the_best_severs[1,], config=config))
glimpse(spd_upload_test(closest_servers[1,], config=config))
@ -107,7 +101,7 @@ 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.
```{r}
```{r moar-dl-tests, cache=TRUE}
set.seed(8675309)
bind_rows(
@ -127,15 +121,11 @@ bind_rows(
ungroup() -> to_compare
select(to_compare, sponsor, name, country, host, type)
```
```{r}
map_df(1:nrow(to_compare), ~{
spd_download_test(to_compare[.x,], config=config, summarise=FALSE, timeout=30)
}) -> dl_results_full
```
```{r}
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) +
@ -153,7 +143,7 @@ mutate(dl_results_full, type=stri_trans_totitle(type)) %>%
Choose closest and "best" and filter duplicates out since we're really trying to measure here vs show the disparity:
```{r}
```{r moar-ul-tests, cache=TRUE}
bind_rows(
closest_servers[1:3,] %>% mutate(type="closest"),
only_the_best_severs[1:3,] %>% mutate(type="best")
@ -165,9 +155,7 @@ 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
```
```{r}
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)) +
@ -181,10 +169,10 @@ ggplot(ul_results_full, aes(x="Upload Test", y=bw)) +
## speedtest Metrics
```{r echo=FALSE}
```{r cloc, echo=FALSE}
cloc::cloc_pkg_md()
```
## Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.
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.

312
README.gfm-ascii_identifiers

@ -1,312 +0,0 @@
speedtest
================
Tools to Test and Compare Internet Bandwidth Speeds
## Description
The ‘Ookla’ ‘Speedtest’ site <http://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.
## What’s Inside The Tin
The following functions are implemented:
- `spd_best_servers`: Find “best” servers (latency-wise) from master
server list
- `spd_closest_servers`: Find “closest” servers (geography-wise) from
master server list
- `spd_compute_bandwidth`: Compute bandwidth from bytes transferred
and time taken
- `spd_config`: Retrieve client configuration information for the
speedtest
- `spd_download_test`: Perform a download speed/bandwidth test
- `spd_servers`: Retrieve a list of SpeedTest servers
- `spd_upload_test`: Perform an upload speed/bandwidth test
- `spd_test`: Test your internet speed/bandwidth
## Make a CLI utility
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:
![](imgs/spdtst.gif)
## TODO
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.
- \[ \] Cache config in memory at startup vs pass around to functions?
- \[ \] Figure out how to use beta sockets hidden API vs the old Flash
API?
- \[ \] Ensure the efficacy of relying on the cURL timings for speed
measures for the Flash API
- \[ \] Figure out best way to capture the results for post-processing
- \[ \] Upload results to speedtest (tis only fair)\!
- \[ \] Incorporate more network or host measures for better
statistical determination of the best target\!
- \[ \] `autoplot` support\!
- \[ \] RStudio Add-in
- \[ \] Shiny app?
## Installation
``` r
devtools::install_github("hrbrmstr/speedtest")
```
``` r
options(width=120)
```
## Usage
``` r
library(speedtest)
library(stringi)
library(hrbrthemes)
library(ggbeeswarm)
library(tidyverse)
# current verison
packageVersion("speedtest")
```
## [1] '0.1.0'
### Download Speed
``` r
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)
```
### Individual download tests
``` r
glimpse(spd_download_test(closest_servers[1,], config=config))
```
## Observations: 1
## Variables: 15
## $ url <chr> "http://speed0.xcelx.net/speedtest/upload.php"
## $ lat <dbl> 42.3875
## $ lng <dbl> -71.1
## $ name <chr> "Somerville, MA"
## $ country <chr> "United States"
## $ cc <chr> "US"
## $ sponsor <chr> "Axcelx Technologies LLC"
## $ id <chr> "5960"
## $ host <chr> "speed0.xcelx.net:8080"
## $ url2 <chr> "http://speed1.xcelx.net/speedtest/upload.php"
## $ min <dbl> 13.24172
## $ mean <dbl> 54.31822
## $ median <dbl> 52.28935
## $ max <dbl> 83.77728
## $ sd <dbl> 26.88115
``` r
glimpse(spd_download_test(only_the_best_severs[1,], config=config))
```
## Observations: 1
## Variables: 18
## $ ping_time <dbl> NaN
## $ total_time <dbl> 0.100793
## $ retrieval_time <dbl> 2.3e-05
## $ url <chr> "http://stosat-ndhm-01.sys.comcast.net/speedtest/upload.php"
## $ lat <dbl> 42.3578
## $ lng <dbl> -71.0617
## $ name <chr> "Boston, MA"
## $ country <chr> "United States"
## $ cc <chr> "US"
## $ sponsor <chr> "Comcast"
## $ id <chr> "1774"
## $ host <chr> "stosat-ndhm-01.sys.comcast.net:8080"
## $ url2 <chr> "http://a-stosat-ndhm-01.sys.comcast.net/speedtest/upload.php"
## $ min <dbl> 13.7987
## $ mean <dbl> 73.27741
## $ median <dbl> 78.4501
## $ max <dbl> 138.8271
## $ sd <dbl> 44.21786
### Individual upload tests
``` r
glimpse(spd_upload_test(only_the_best_severs[1,], config=config))
```
## Observations: 1
## Variables: 18
## $ ping_time <dbl> NaN
## $ total_time <dbl> 0.100793
## $ retrieval_time <dbl> 2.3e-05
## $ url <chr> "http://stosat-ndhm-01.sys.comcast.net/speedtest/upload.php"
## $ lat <dbl> 42.3578
## $ lng <dbl> -71.0617
## $ name <chr> "Boston, MA"
## $ country <chr> "United States"
## $ cc <chr> "US"
## $ sponsor <chr> "Comcast"
## $ id <chr> "1774"
## $ host <chr> "stosat-ndhm-01.sys.comcast.net:8080"
## $ url2 <chr> "http://a-stosat-ndhm-01.sys.comcast.net/speedtest/upload.php"
## $ min <dbl> 3.868808
## $ mean <dbl> 6.25797
## $ median <dbl> 6.165482
## $ max <dbl> 8.921862
## $ sd <dbl> 1.796898
``` r
glimpse(spd_upload_test(closest_servers[1,], config=config))
```
## Observations: 1
## Variables: 15
## $ url <chr> "http://speed0.xcelx.net/speedtest/upload.php"
## $ lat <dbl> 42.3875
## $ lng <dbl> -71.1
## $ name <chr> "Somerville, MA"
## $ country <chr> "United States"
## $ cc <chr> "US"
## $ sponsor <chr> "Axcelx Technologies LLC"
## $ id <chr> "5960"
## $ host <chr> "speed0.xcelx.net:8080"
## $ url2 <chr> "http://speed1.xcelx.net/speedtest/upload.php"
## $ min <dbl> 3.554852
## $ mean <dbl> 9.124757
## $ median <dbl> 10.5464
## $ max <dbl> 11.94891
## $ sd <dbl> 3.464799
### Moar download tests
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.
``` r
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)
```
## # A tibble: 9 x 5
## sponsor name country host type
## <chr> <chr> <chr> <chr> <chr>
## 1 Axcelx Technologies LLC Somerville, MA United States speed0.xcelx.net:8080 closest
## 2 Comcast Boston, MA United States stosat-ndhm-01.sys.comcast.net:8080 closest
## 3 Starry, Inc. Boston, MA United States speedtest-server.starry.com:8080 closest
## 4 Comcast Boston, MA United States stosat-ndhm-01.sys.comcast.net:8080 best
## 5 Axcelx Technologies LLC Somerville, MA United States speed0.xcelx.net:8080 best
## 6 Norwood Light Broadband Norwood, MA United States speedtest.norwoodlight.com:8080 best
## 7 Rudzkie Sieci Komputerowe Ruda Śląska Poland sp1.rsknet.pl:8080 random
## 8 AT&T Los Angeles, CA United States lax.speedtest.sbcglobal.net:8080 random
## 9 UP Telecom Lucena Brazil sp1.bandalargaup.com.br:8080 random
``` r
map_df(1:nrow(to_compare), ~{
spd_download_test(to_compare[.x,], config=config, summarise=FALSE, timeout=30)
}) -> dl_results_full
```
``` r
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), labels=c(sprintf("%s", seq(0,150,50)), "200 Mb/s"), limits=c(0,200)) +
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")
```
<img src="README.gfm-ascii_identifiers_files/figure-gfm/unnamed-chunk-10-1.png" width="672" />
### Moar upload tests
Choose closest and “best” and filter duplicates out since we’re really
trying to measure here vs show the disparity:
``` r
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)
```
## # A tibble: 6 x 5
## sponsor name country host type
## <chr> <chr> <chr> <chr> <chr>
## 1 Axcelx Technologies LLC Somerville, MA United States speed0.xcelx.net:8080 closest
## 2 Comcast Boston, MA United States stosat-ndhm-01.sys.comcast.net:8080 closest
## 3 Starry, Inc. Boston, MA United States speedtest-server.starry.com:8080 closest
## 4 Comcast Boston, MA United States stosat-ndhm-01.sys.comcast.net:8080 best
## 5 Axcelx Technologies LLC Somerville, MA United States speed0.xcelx.net:8080 best
## 6 Norwood Light Broadband Norwood, MA United States speedtest.norwoodlight.com:8080 best
``` r
map_df(1:nrow(to_compare), ~{
spd_upload_test(to_compare[.x,], config=config, summarise=FALSE, timeout=30)
}) -> ul_results_full
```
``` r
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), breaks=seq(0,16,4),
labels=c(sprintf("%s", seq(0,12,4)), "16 Mb/s"), limits=c(0,16)) +
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")
```
<img src="README.gfm-ascii_identifiers_files/figure-gfm/unnamed-chunk-12-1.png" width="672" />
## Code of Conduct
Please note that this project is released with a [Contributor Code of
Conduct](CONDUCT.md). By participating in this project you agree to
abide by its terms.

BIN
README.gfm-ascii_identifiers_files/figure-gfm/unnamed-chunk-10-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 113 KiB

BIN
README.gfm-ascii_identifiers_files/figure-gfm/unnamed-chunk-11-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

BIN
README.gfm-ascii_identifiers_files/figure-gfm/unnamed-chunk-12-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

BIN
README.gfm-ascii_identifiers_files/figure-gfm/unnamed-chunk-5-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

BIN
README.gfm-ascii_identifiers_files/figure-gfm/unnamed-chunk-7-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

BIN
README.gfm-ascii_identifiers_files/figure-gfm/unnamed-chunk-9-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

269
README.md

@ -1,6 +1,23 @@
speedtest
================
[![Project Status: Active – The project has reached a stable, usable
state and is being actively
developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Signed
by](https://img.shields.io/badge/Keybase-Verified-brightgreen.svg)](https://keybase.io/hrbrmstr)
![Signed commit
%](https://img.shields.io/badge/Signed_Commits-21.7%25-lightgrey.svg)
[![Linux build
Status](https://travis-ci.org/hrbrmstr/speedtest.svg?branch=master)](https://travis-ci.org/hrbrmstr/speedtest)
[![Coverage
Status](https://codecov.io/gh/hrbrmstr/speedtest/branch/master/graph/badge.svg)](https://codecov.io/gh/hrbrmstr/speedtest)
![Minimal R
Version](https://img.shields.io/badge/R%3E%3D-3.2.0-blue.svg)
![License](https://img.shields.io/badge/License-MIT-blue.svg)
# speedtest
Tools to Test and Compare Internet Bandwidth Speeds
## Description
@ -15,6 +32,9 @@ for testing and performing speed/bandwidth tests.
The following functions are implemented:
- `nice_speed`: Convert a test speed, in Mbits/s, to its string
representation along with appropriate units for the magnitude of the
test speed
- `spd_best_servers`: Find “best” servers (latency-wise) from master
server list
- `spd_closest_servers`: Find “closest” servers (geography-wise) from
@ -25,8 +45,8 @@ The following functions are implemented:
speedtest
- `spd_download_test`: Perform a download speed/bandwidth test
- `spd_servers`: Retrieve a list of SpeedTest servers
- `spd_upload_test`: Perform an upload speed/bandwidth test
- `spd_test`: Test your internet speed/bandwidth
- `spd_upload_test`: Perform an upload speed/bandwidth test
## Make a CLI utility
@ -39,7 +59,7 @@ fleet-of-finger/have dexterous digits:
which will look something like:
![](imgs/spdtst.gif)
![](man/figures/spdtst.gif)
## TODO
@ -63,12 +83,21 @@ we shld” kinda thing. Ones with exclamation marks are essentials.
## Installation
``` r
devtools::install_github("hrbrmstr/speedtest")
install.packages("speedtest", repos = "https://cinc.rud.is")
# or
remotes::install_git("https://git.rud.is/hrbrmstr/speedtest.git")
# or
remotes::install_git("https://git.sr.ht/~hrbrmstr/speedtest")
# or
remotes::install_gitlab("hrbrmstr/speedtest")
# or
remotes::install_bitbucket("hrbrmstr/speedtest")
# or
remotes::install_github("hrbrmstr/speedtest")
```
``` r
options(width=120)
```
NOTE: To use the ‘remotes’ install options you will need to have the
[{remotes} package](https://github.com/r-lib/remotes) installed.
## Usage
@ -81,10 +110,9 @@ library(tidyverse)
# current verison
packageVersion("speedtest")
## [1] '0.2.0'
```
## [1] '0.1.0'
### Download Speed
``` r
@ -99,100 +127,90 @@ only_the_best_severs <- spd_best_servers(closest_servers, config)
``` r
glimpse(spd_download_test(closest_servers[1,], config=config))
```
## Observations: 1
## Variables: 15
## $ url <chr> "http://speed0.xcelx.net/speedtest/upload.php"
## $ lat <dbl> 42.3875
## $ lng <dbl> -71.1
## $ name <chr> "Somerville, MA"
## $ country <chr> "United States"
## $ cc <chr> "US"
## $ sponsor <chr> "Axcelx Technologies LLC"
## $ id <chr> "5960"
## $ host <chr> "speed0.xcelx.net:8080"
## $ url2 <chr> "http://speed1.xcelx.net/speedtest/upload.php"
## $ min <dbl> 14.40439
## $ mean <dbl> 60.06834
## $ median <dbl> 55.28457
## $ max <dbl> 127.9436
## $ sd <dbl> 34.20695
## Observations: 1
## Variables: 15
## $ url <chr> "http://oak-speedtest.otelco.com:8080/speedtest/upload.php"
## $ lat <dbl> 43.6614
## $ lng <dbl> -70.2558
## $ name <chr> "Portland, ME"
## $ country <chr> "United States"
## $ cc <chr> "US"
## $ sponsor <chr> "Otelco"
## $ id <chr> "1037"
## $ host <chr> "oak-speedtest.otelco.com:8080"
## $ url2 <chr> "http://66.181.127.42/speedtest/upload.php"
## $ min <dbl> 12.16723
## $ mean <dbl> 14.91807
## $ median <dbl> 14.57376
## $ max <dbl> 17.30854
## $ sd <dbl> 1.736132
``` r
glimpse(spd_download_test(only_the_best_severs[1,], config=config))
## Observations: 1
## Variables: 17
## $ total_time <dbl> 0.075129
## $ retrieval_time <dbl> 2.8e-05
## $ url <chr> "http://stosat-ndhm-01.sys.comcast.net:8080/speedtest/upload.php"
## $ lat <dbl> 42.3578
## $ lng <dbl> -71.0617
## $ name <chr> "Boston, MA"
## $ country <chr> "United States"
## $ cc <chr> "US"
## $ sponsor <chr> "Comcast"
## $ id <chr> "1774"
## $ host <chr> "stosat-ndhm-01.sys.comcast.net:8080"
## $ url2 <chr> "http://a-stosat-ndhm-01.sys.comcast.net/speedtest/upload.php"
## $ min <dbl> 14.49186
## $ mean <dbl> 17.68452
## $ median <dbl> 16.75617
## $ max <dbl> 24.3737
## $ sd <dbl> 2.987197
```
## Observations: 1
## Variables: 18
## $ ping_time <dbl> 0.02712567
## $ total_time <dbl> 0.059917
## $ retrieval_time <dbl> 2.3e-05
## $ url <chr> "http://speed0.xcelx.net/speedtest/upload.php"
## $ lat <dbl> 42.3875
## $ lng <dbl> -71.1
## $ name <chr> "Somerville, MA"
## $ country <chr> "United States"
## $ cc <chr> "US"
## $ sponsor <chr> "Axcelx Technologies LLC"
## $ id <chr> "5960"
## $ host <chr> "speed0.xcelx.net:8080"
## $ url2 <chr> "http://speed1.xcelx.net/speedtest/upload.php"
## $ min <dbl> 14.64922
## $ mean <dbl> 56.15303
## $ median <dbl> 51.89162
## $ max <dbl> 107.5084
## $ sd <dbl> 31.8866
### Individual upload tests
``` r
glimpse(spd_upload_test(only_the_best_severs[1,], config=config))
```
## Observations: 1
## Variables: 18
## $ ping_time <dbl> 0.02712567
## $ total_time <dbl> 0.059917
## $ retrieval_time <dbl> 2.3e-05
## $ url <chr> "http://speed0.xcelx.net/speedtest/upload.php"
## $ lat <dbl> 42.3875
## $ lng <dbl> -71.1
## $ name <chr> "Somerville, MA"
## $ country <chr> "United States"
## $ cc <chr> "US"
## $ sponsor <chr> "Axcelx Technologies LLC"
## $ id <chr> "5960"
## $ host <chr> "speed0.xcelx.net:8080"
## $ url2 <chr> "http://speed1.xcelx.net/speedtest/upload.php"
## $ min <dbl> 6.240858
## $ mean <dbl> 9.527599
## $ median <dbl> 9.303148
## $ max <dbl> 12.56686
## $ sd <dbl> 2.451778
## Observations: 1
## Variables: 17
## $ total_time <dbl> 0.075129
## $ retrieval_time <dbl> 2.8e-05
## $ url <chr> "http://stosat-ndhm-01.sys.comcast.net:8080/speedtest/upload.php"
## $ lat <dbl> 42.3578
## $ lng <dbl> -71.0617
## $ name <chr> "Boston, MA"
## $ country <chr> "United States"
## $ cc <chr> "US"
## $ sponsor <chr> "Comcast"
## $ id <chr> "1774"
## $ host <chr> "stosat-ndhm-01.sys.comcast.net:8080"
## $ url2 <chr> "http://a-stosat-ndhm-01.sys.comcast.net/speedtest/upload.php"
## $ min <dbl> 9.951216
## $ mean <dbl> 20.33949
## $ median <dbl> 22.11265
## $ max <dbl> 23.4545
## $ sd <dbl> 5.148238
``` r
glimpse(spd_upload_test(closest_servers[1,], config=config))
## Observations: 1
## Variables: 15
## $ url <chr> "http://oak-speedtest.otelco.com:8080/speedtest/upload.php"
## $ lat <dbl> 43.6614
## $ lng <dbl> -70.2558
## $ name <chr> "Portland, ME"
## $ country <chr> "United States"
## $ cc <chr> "US"
## $ sponsor <chr> "Otelco"
## $ id <chr> "1037"
## $ host <chr> "oak-speedtest.otelco.com:8080"
## $ url2 <chr> "http://66.181.127.42/speedtest/upload.php"
## $ min <dbl> 5.646166
## $ mean <dbl> 16.96393
## $ median <dbl> 19.76833
## $ max <dbl> 22.18757
## $ sd <dbl> 6.542608
```
## Observations: 1
## Variables: 15
## $ url <chr> "http://speed0.xcelx.net/speedtest/upload.php"
## $ lat <dbl> 42.3875
## $ lng <dbl> -71.1
## $ name <chr> "Somerville, MA"
## $ country <chr> "United States"
## $ cc <chr> "US"
## $ sponsor <chr> "Axcelx Technologies LLC"
## $ id <chr> "5960"
## $ host <chr> "speed0.xcelx.net:8080"
## $ url2 <chr> "http://speed1.xcelx.net/speedtest/upload.php"
## $ min <dbl> 6.764702
## $ mean <dbl> 9.896179
## $ median <dbl> 10.3605
## $ max <dbl> 12.85389
## $ sd <dbl> 2.359868
### Moar download tests
Choose closest, “best” and randomly (there can be, and are, some dups as
@ -222,29 +240,23 @@ bind_rows(
ungroup() -> to_compare
select(to_compare, sponsor, name, country, host, type)
```
## # A tibble: 9 x 5
## sponsor name country host type
## <chr> <chr> <chr> <chr> <chr>
## 1 Otelco Portland, ME United States oak-speedtest.otelco.com:8080 closest
## 2 netBlazr Somerville, MA United States speed0.xcelx.net:8080 closest
## 3 Comcast Boston, MA United States stosat-ndhm-01.sys.comcast.net:8080 closest
## 4 Comcast Boston, MA United States stosat-ndhm-01.sys.comcast.net:8080 best
## 5 netBlazr Somerville, MA United States speed0.xcelx.net:8080 best
## 6 BELD Broadband Braintree, MA United States wotan.beld.net:8080 best
## 7 LLC Trans Analitika Novaya Usman Russian Federation speedtest-1.cnetvrn.ru:8080 random
## 8 VEGA Kharkiv Kharkiv Ukraine speedtest.vega.com.ua:8080 random
## 9 Oxylion S.A Katowice Poland speedtest-kat-01.oxylion.net.pl:8080 random
## # A tibble: 9 x 5
## sponsor name country
## <chr> <chr> <chr>
## 1 Axcelx Technologies LLC Somerville, MA United States
## 2 Comcast Boston, MA United States
## 3 Starry, Inc. Boston, MA United States
## 4 Axcelx Technologies LLC Somerville, MA United States
## 5 Norwood Light Broadband Norwood, MA United States
## 6 CCI - New England Providence, RI United States
## 7 PirxNet Gliwice Poland
## 8 Interoute VDC Los Angeles, CA United States
## 9 UNPAD Bandung Indonesia
## # ... with 2 more variables: host <chr>, type <chr>
``` r
map_df(1:nrow(to_compare), ~{
spd_download_test(to_compare[.x,], config=config, summarise=FALSE, timeout=30)
}) -> dl_results_full
```
``` r
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) +
@ -258,7 +270,7 @@ mutate(dl_results_full, type=stri_trans_totitle(type)) %>%
theme(legend.position="none")
```
<img src="README_files/figure-gfm/unnamed-chunk-10-1.png" width="672" />
<img src="man/figures/README-moar-dl-tests-1.png" width="672" />
### Moar upload tests
@ -273,26 +285,20 @@ bind_rows(
distinct(.keep_all=TRUE) -> to_compare
select(to_compare, sponsor, name, country, host, type)
```
## # A tibble: 6 x 5
## sponsor name country
## <chr> <chr> <chr>
## 1 Axcelx Technologies LLC Somerville, MA United States
## 2 Comcast Boston, MA United States
## 3 Starry, Inc. Boston, MA United States
## 4 Axcelx Technologies LLC Somerville, MA United States
## 5 Norwood Light Broadband Norwood, MA United States
## 6 CCI - New England Providence, RI United States
## # ... with 2 more variables: host <chr>, type <chr>
## # A tibble: 6 x 5
## sponsor name country host type
## <chr> <chr> <chr> <chr> <chr>
## 1 Otelco Portland, ME United States oak-speedtest.otelco.com:8080 closest
## 2 netBlazr Somerville, MA United States speed0.xcelx.net:8080 closest
## 3 Comcast Boston, MA United States stosat-ndhm-01.sys.comcast.net:8080 closest
## 4 Comcast Boston, MA United States stosat-ndhm-01.sys.comcast.net:8080 best
## 5 netBlazr Somerville, MA United States speed0.xcelx.net:8080 best
## 6 BELD Broadband Braintree, MA United States wotan.beld.net:8080 best
``` r
map_df(1:nrow(to_compare), ~{
spd_upload_test(to_compare[.x,], config=config, summarise=FALSE, timeout=30)
}) -> ul_results_full
```
``` r
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)) +
@ -304,19 +310,18 @@ ggplot(ul_results_full, aes(x="Upload Test", y=bw)) +
theme(legend.position="none")
```
<img src="README_files/figure-gfm/unnamed-chunk-12-1.png" width="672" />
<img src="man/figures/README-moar-ul-tests-1.png" width="672" />
## speedtest Metrics
| Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) |
| :--- | -------: | ---: | --: | ---: | ----------: | ---: | -------: | ---: |
| HTML | 1 | 0.06 | 819 | 0.73 | 10 | 0.07 | 0 | 0.00 |
| R | 13 | 0.81 | 215 | 0.19 | 70 | 0.51 | 167 | 0.68 |
| Rmd | 1 | 0.06 | 64 | 0.06 | 49 | 0.36 | 78 | 0.32 |
| make | 1 | 0.06 | 20 | 0.02 | 9 | 0.07 | 0 | 0.00 |
| R | 13 | 0.87 | 226 | 0.73 | 68 | 0.53 | 180 | 0.74 |
| Rmd | 1 | 0.07 | 64 | 0.21 | 51 | 0.40 | 63 | 0.26 |
| make | 1 | 0.07 | 20 | 0.06 | 9 | 0.07 | 0 | 0.00 |
## Code of Conduct
Please note that this project is released with a [Contributor Code of
Conduct](CONDUCT.md). By participating in this project you agree to
abide by its terms.
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.

3
README_cache/gfm/__packages

@ -12,6 +12,3 @@ purrr
dplyr
stringr
forcats
bindrcpp
devtools
usethis

BIN
README_cache/gfm/dl-speeed_31ed0600c0555b226365c572514c60ee.RData

Binary file not shown.

BIN
README_cache/gfm/dl-speeed_31ed0600c0555b226365c572514c60ee.rdb

Binary file not shown.

BIN
README_cache/gfm/dl-speeed_31ed0600c0555b226365c572514c60ee.rdx

Binary file not shown.

BIN
README_cache/gfm/individ-dl_d8acf06a65b57ecf7a891dff9743a153.RData

Binary file not shown.

0
README_cache/gfm/unnamed-chunk-7_c4f4f0b44c2fc2d6ee8870ae77830ebf.rdb → README_cache/gfm/individ-dl_d8acf06a65b57ecf7a891dff9743a153.rdb

BIN
README_cache/gfm/individ-dl_d8acf06a65b57ecf7a891dff9743a153.rdx

Binary file not shown.

BIN
README_cache/gfm/individ-up_bef9661be29204fe5a1fe1a9df42e3bf.RData

Binary file not shown.

0
README_cache/gfm/unnamed-chunk-6_a08421919cfedfed307e2451eebc3090.rdb → README_cache/gfm/individ-up_bef9661be29204fe5a1fe1a9df42e3bf.rdb

BIN
README_cache/gfm/individ-up_bef9661be29204fe5a1fe1a9df42e3bf.rdx

Binary file not shown.

BIN
README_cache/gfm/moar-dl-tests_21cafef69b9f6499b9aa8b2c347a598f.RData

Binary file not shown.

BIN
README_cache/gfm/moar-dl-tests_21cafef69b9f6499b9aa8b2c347a598f.rdb

Binary file not shown.

BIN
README_cache/gfm/moar-dl-tests_21cafef69b9f6499b9aa8b2c347a598f.rdx

Binary file not shown.

BIN
README_cache/gfm/moar-ul-tests_8bc45b6683652bd85c8272cd2dabb5e1.RData

Binary file not shown.

BIN
README_cache/gfm/moar-ul-tests_8bc45b6683652bd85c8272cd2dabb5e1.rdb

Binary file not shown.

BIN
README_cache/gfm/moar-ul-tests_8bc45b6683652bd85c8272cd2dabb5e1.rdx

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-10_a05d32b06c329a82c57de508b8e165c1.RData

Binary file not shown.

0
README_cache/gfm/unnamed-chunk-10_a05d32b06c329a82c57de508b8e165c1.rdb

BIN
README_cache/gfm/unnamed-chunk-10_a05d32b06c329a82c57de508b8e165c1.rdx

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-11_7def8c4e0574346221b17493aa83ccd1.RData

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-11_7def8c4e0574346221b17493aa83ccd1.rdb

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-11_7def8c4e0574346221b17493aa83ccd1.rdx

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-12_c763d3cf0c31639005806c1f67aa0e19.RData

Binary file not shown.

0
README_cache/gfm/unnamed-chunk-12_c763d3cf0c31639005806c1f67aa0e19.rdb

BIN
README_cache/gfm/unnamed-chunk-12_c763d3cf0c31639005806c1f67aa0e19.rdx

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-13_ea042d41f7055d0784f2db8b8df9b01a.RData

Binary file not shown.

0
README_cache/gfm/unnamed-chunk-13_ea042d41f7055d0784f2db8b8df9b01a.rdb

BIN
README_cache/gfm/unnamed-chunk-13_ea042d41f7055d0784f2db8b8df9b01a.rdx

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-2_5b0ba01bb43aefa1232c8b724a6601e4.RData

Binary file not shown.

0
README_cache/gfm/unnamed-chunk-2_5b0ba01bb43aefa1232c8b724a6601e4.rdb

BIN
README_cache/gfm/unnamed-chunk-2_5b0ba01bb43aefa1232c8b724a6601e4.rdx

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-3_c2d6adad80c87c748cd07e4fbf805a99.RData

Binary file not shown.

0
README_cache/gfm/unnamed-chunk-3_c2d6adad80c87c748cd07e4fbf805a99.rdb

BIN
README_cache/gfm/unnamed-chunk-3_c2d6adad80c87c748cd07e4fbf805a99.rdx

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-4_bb201e0df1071cb65b54fdc9bebf413d.RData

Binary file not shown.

0
README_cache/gfm/unnamed-chunk-4_bb201e0df1071cb65b54fdc9bebf413d.rdb

BIN
README_cache/gfm/unnamed-chunk-4_bb201e0df1071cb65b54fdc9bebf413d.rdx

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-5_08af825d6f4cb3312e5f922882aff56f.RData

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-5_08af825d6f4cb3312e5f922882aff56f.rdb

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-5_08af825d6f4cb3312e5f922882aff56f.rdx

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-6_a08421919cfedfed307e2451eebc3090.RData

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-6_a08421919cfedfed307e2451eebc3090.rdx

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-7_c4f4f0b44c2fc2d6ee8870ae77830ebf.RData

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-7_c4f4f0b44c2fc2d6ee8870ae77830ebf.rdx

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-8_589608964690a85b75a2c454d204378e.RData

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-8_589608964690a85b75a2c454d204378e.rdb

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-8_589608964690a85b75a2c454d204378e.rdx

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-9_c2b4b56b83ed174d8c32859946fd3840.RData

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-9_c2b4b56b83ed174d8c32859946fd3840.rdb

Binary file not shown.

BIN
README_cache/gfm/unnamed-chunk-9_c2b4b56b83ed174d8c32859946fd3840.rdx

Binary file not shown.

BIN
README_files/figure-gfm/unnamed-chunk-10-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 KiB

BIN
README_files/figure-gfm/unnamed-chunk-11-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

BIN
README_files/figure-gfm/unnamed-chunk-12-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

BIN
README_files/figure-gfm/unnamed-chunk-9-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

45
appveyor.yml

@ -0,0 +1,45 @@
# DO NOT CHANGE the "init" and "install" sections below
# Download script file from GitHub
init:
ps: |
$ErrorActionPreference = "Stop"
Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1"
Import-Module '..\appveyor-tool.ps1'
install:
ps: Bootstrap
cache:
- C:\RLibrary
# Adapt as necessary starting from here
build_script:
- travis-tool.sh install_deps
test_script:
- travis-tool.sh run_tests
on_failure:
- 7z a failure.zip *.Rcheck\*
- appveyor PushArtifact failure.zip
artifacts:
- path: '*.Rcheck\**\*.log'
name: Logs
- path: '*.Rcheck\**\*.out'
name: Logs
- path: '*.Rcheck\**\*.fail'
name: Logs
- path: '*.Rcheck\**\*.Rout'
name: Logs
- path: '\*_*.tar.gz'
name: Bits
- path: '\*_*.zip'
name: Bits

8
inst/tinytest/test_speedtest.R

@ -0,0 +1,8 @@
library(speedtest)
# speeds are displayed in appropriate units
expect_true(grepl("Kbit/s", nice_speed(0.1)))
expect_true(grepl("Mbit/s", nice_speed(1)))
expect_true(grepl("Gbit/s", nice_speed(1000)))
expect_true(all(c("client", "odometer") %in% names(spd_config())))

BIN
man/figures/README-moar-dl-tests-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
man/figures/README-moar-ul-tests-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

0
imgs/spdtst.gif → man/figures/spdtst.gif

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

19
man/nice_speed.Rd

@ -0,0 +1,19 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/util.r
\name{nice_speed}
\alias{nice_speed}
\title{Convert a test speed, in Mbits/s, to its string representation along with
appropriate units for the magnitude of the test speed}
\usage{
nice_speed(number)
}
\arguments{
\item{number}{numeric The speed to be converted}
}
\value{
character The character representation of the speed
}
\description{
- Assumes number is in Mbits/s to start off with
- Only chooses between Kbit/s, Mbit/s, and Gbit/s
}

12
man/pipe.Rd

@ -0,0 +1,12 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils-pipe.R
\name{\%>\%}
\alias{\%>\%}
\title{Pipe operator}
\usage{
lhs \%>\% rhs
}
\description{
See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details.
}
\keyword{internal}

4
man/spd_download_test.Rd

@ -4,8 +4,8 @@
\alias{spd_download_test}
\title{Perform a download speed/bandwidth test}
\usage{
spd_download_test(server, config = NULL, summarise = TRUE, timeout = 60,
.progress = "dplyr")
spd_download_test(server, config = NULL, summarise = TRUE,
timeout = 60, .progress = "dplyr")
}
\arguments{
\item{server}{a data frame row from one of the functions that retrieves or

4
man/spd_upload_test.Rd

@ -4,8 +4,8 @@
\alias{spd_upload_test}
\title{Perform an upload speed/bandwidth test}
\usage{
spd_upload_test(server, config = NULL, summarise = TRUE, timeout = 60,
.progress = "dplyr")
spd_upload_test(server, config = NULL, summarise = TRUE,
timeout = 60, .progress = "dplyr")
}
\arguments{
\item{server}{a data frame row from one of the functions that retrieves or

10
man/speedtest.Rd

@ -6,12 +6,20 @@
\alias{speedtest-package}
\title{Tools to Test and Compare Internet Bandwidth Speeds}
\description{
The 'Ookla' 'Speedtest' site \url{http://beta.speedtest.net/about} provides
The 'Ookla' 'Speedtest' site \url{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.
}
\seealso{
Useful links:
\itemize{
\item \url{https://gitlab.com/hrbrmstr/speedtest}
\item Report bugs at \url{https://gitlab.com/hrbrmstr/speedtest/issues}
}
}
\author{
Bob Rudis (bob@rud.is)
}

2
tests/test-all.R

@ -1,2 +0,0 @@
library(testthat)
test_check("speedtest")

12
tests/testthat/test-speedtest.R

@ -1,12 +0,0 @@
context("basic functionality")
test_that("we can do something", {
#expect_that(some_function(), is_a("data.frame"))
})
test_that("speeds are displayed in appropriate units", {
expect_match(nice_speed(0.1), "Kbit/s")
expect_match(nice_speed(1), "Mbit/s")
expect_match(nice_speed(1000), "Gbit/s")
})

5
tests/tinytest.R

@ -0,0 +1,5 @@
if ( requireNamespace("tinytest", quietly=TRUE) ){
tinytest::test_package("speedtest")
}
Loading…
Cancel
Save