mirror of https://git.sr.ht/~hrbrmstr/speedtest
boB Rudis
4 years ago
47 changed files with 243 additions and 73 deletions
@ -0,0 +1,2 @@ |
|||
This package was submitted to CRAN on 2019-07-24. |
|||
Once it is accepted, delete this file and tag the release (commit 38718d8910). |
@ -0,0 +1,15 @@ |
|||
#' Provides instructions for installing the official speedtest CLI application |
|||
#' |
|||
#' @export |
|||
install_speedtest_cli <- function() { |
|||
|
|||
utils::browseURL("https://www.speedtest.net/apps/cli") |
|||
|
|||
warning( |
|||
"You will need to run speedtest once manually so you ", |
|||
"can accept the Ookla license. Failure to do so will ", |
|||
"result in errors generated by the use of speedtest_cli().", |
|||
call. = FALSE |
|||
) |
|||
|
|||
} |
@ -0,0 +1,78 @@ |
|||
#' Perform an official Ookla Speed Test via their command line tools |
|||
#' |
|||
#' @export |
|||
speedtest_cli <- function(progress = TRUE) { |
|||
|
|||
spdtst <- Sys.which(c("speedtest", "speedtest.exe")) |
|||
spdtst <- spdtst[spdtst != ""] |
|||
|
|||
if (length(spdtst) == 0) { |
|||
stop( |
|||
"speedtest cli executable not found. ", |
|||
"Use install_speedtest_cli() to install it.", |
|||
call. = FALSE |
|||
) |
|||
} |
|||
|
|||
progress <- if (progress[1]) "yes" else "no" |
|||
progress <- sprintf("--progress=%s", progress) |
|||
|
|||
args <- c(progress, "--format=jsonl") |
|||
|
|||
system2( |
|||
spdtst, |
|||
args = args, |
|||
TRUE |
|||
) -> res |
|||
|
|||
res <- lapply(res, jsonlite::fromJSON) |
|||
|
|||
download <- list() |
|||
upload <- list() |
|||
result <- list() |
|||
|
|||
for (.x in res) { |
|||
|
|||
if (.x$type == "download") { |
|||
download <- append(download, list(.x)) |
|||
} else if (.x$type == "upload") { |
|||
upload <- append(upload, list(.x)) |
|||
} else { |
|||
result <- append(result, list(.x)) |
|||
} |
|||
|
|||
} |
|||
|
|||
list( |
|||
download = dplyr::bind_rows(lapply(download, dplyr::as_tibble)), |
|||
upload = dplyr::bind_rows(lapply(upload, dplyr::as_tibble)), |
|||
result = result |
|||
) -> res |
|||
|
|||
class(res) <- c("speedtest_cli_result") |
|||
|
|||
res |
|||
|
|||
} |
|||
|
|||
#' @rdname speedtest_cli |
|||
#' @param x `speedtest_cli_result` object |
|||
#' @param browse if `TRUE`, open a browser window with the results |
|||
#' @param ... ignored |
|||
#' @export |
|||
print.speedtest_cli_result <- function(x, browse = FALSE, ...) { |
|||
|
|||
fmt <- scales::label_number_si(accuracy = 0.001, unit = "") |
|||
|
|||
cat( |
|||
"Provider: ", x$result[[7]]$isp, "\n", |
|||
" Ping: ", x$result[[7]]$ping$latency, " ms\n", |
|||
"Download: ", fmt(x$result[[7]]$download$bytes), "\n", |
|||
" Upload: ", fmt(x$result[[7]]$upload$bytes), "\n", |
|||
" URL: ", x$result[[7]]$result$url, |
|||
sep = "" |
|||
) |
|||
|
|||
if (browse) utils::browseURL(x$result[[7]]$result$url) |
|||
|
|||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,19 @@ |
|||
## Test environments |
|||
* local OS X install, R 3.6.1 |
|||
* ubuntu 14.04 (on travis-ci), R 3.6.1 |
|||
* win-builder (devel and release) |
|||
|
|||
## R CMD check results |
|||
|
|||
0 errors | 0 warnings | 1 note |
|||
|
|||
* This is a new release. |
|||
|
|||
-------------------- |
|||
|
|||
Nothing was flagged in winbuilder(s) so shld hopefully |
|||
work on the CRAN pre-test infra. |
|||
|
|||
There is one live test requiring network connectivbity to |
|||
retrieve a config from speedtest & verify the results. |
|||
I can remove that if desired. |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 21 KiB |
@ -0,0 +1,11 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/install-speedtest-cli.R |
|||
\name{install_speedtest_cli} |
|||
\alias{install_speedtest_cli} |
|||
\title{Provides instructions for installing the official speedtest CLI application} |
|||
\usage{ |
|||
install_speedtest_cli() |
|||
} |
|||
\description{ |
|||
Provides instructions for installing the official speedtest CLI application |
|||
} |
@ -0,0 +1,21 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/speedtest-cli.R |
|||
\name{speedtest_cli} |
|||
\alias{speedtest_cli} |
|||
\alias{print.speedtest_cli_result} |
|||
\title{Perform an official Ookla Speed Test via their command line tools} |
|||
\usage{ |
|||
speedtest_cli(progress = TRUE) |
|||
|
|||
\method{print}{speedtest_cli_result}(x, browse = FALSE, ...) |
|||
} |
|||
\arguments{ |
|||
\item{x}{`speedtest_cli_result` object} |
|||
|
|||
\item{browse}{if `TRUE`, open a browser window with the results} |
|||
|
|||
\item{...}{ignored} |
|||
} |
|||
\description{ |
|||
Perform an official Ookla Speed Test via their command line tools |
|||
} |
Loading…
Reference in new issue