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

Calculate download time from file size #9

Open
k5cents opened this issue Feb 27, 2020 · 3 comments
Open

Calculate download time from file size #9

k5cents opened this issue Feb 27, 2020 · 3 comments
Assignees

Comments

@k5cents
Copy link

k5cents commented Feb 27, 2020

It might be handy if this package implemented some functions to take a file size and download speed and calculate the time needed to download.

Remembering how to go from MB to Mbps to seconds, etc is confusing.

# check file head size
tx_url <- "https://www.ethics.state.tx.us/data/search/cf/TEC_CF_CSV.zip"
tx_head <- httr::HEAD(url = tx_url)
(tx_length <- fs::as_fs_bytes(httr::headers(tx_head)[["content-length"]]))
#> 541M
# test download speed
config <- speedtest::spd_config()
servers <- speedtest::spd_servers(config = config)
closest_servers <- speedtest::spd_closest_servers(servers, config = config)
speed <- speedtest::spd_download_test(closest_servers[1, ], config = config)
speed[, 11:15]
#> # A tibble: 1 x 5
#>     min  mean median   max    sd
#>   <dbl> <dbl>  <dbl> <dbl> <dbl>
#> 1  6.55  34.6   38.2  61.2  19.4
# seconds to download
((as.numeric(tx_length)/1e+6) / (speed$median / 8))
#> [1] 118.6992

Created on 2020-02-27 by the reprex package (v0.3.0)

@hrbrmstr
Copy link
Owner

I'm pinging @briandconnelly to this as I recall hearing something abt an official speedtest R pkg coming out and wld prbly PR into that for this functionality vs maintain this pkg.

@hrbrmstr hrbrmstr self-assigned this Feb 27, 2020
@briandconnelly
Copy link

Good news / bad news. We do have an official R package for Speedtest that's done and ready to go. The bad news is that it hasn't cleared legal yet, and I don't have an estimate for when it will.

image

In the meantime (and not to discourage use/development of @hrbrmstr's package!), I will mention that the official CLI tool does offer configurable units (e.g., Mbps, kiB/s, etc.) so you don't have to do any conversion, and its output is easy to import into R.

@hrbrmstr
Copy link
Owner

speedtest -f json FTW!

Imagonna add support for the CLI (i.e. calling it from R and handling the output) and then make this estimator @kiernann requested.

I'll prbly rename the pkg as well to avoid confusion with the legit one that will eventually come out.

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

No branches or pull requests

3 participants