Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to add a speed test to my BASH script. I know you can install speedtest-cli on the host, but this is not an option. I'm looking for options perhaps using the CURL command.

What I have tried:

I tried using a CURL command to obtain the BPS when transferring a file from Box:

speed_bps=$(curl -Lo /dev/null -skw "%{speed_download}" $DownloadTestURL)
speed_bps=$(printf "%.0f\n" "$speed_bps")


But I'm a bit confused by the BPS - Mbps conversion. For example, my internet speed is ~100M, confirmed by going to http://speedtest.net.

However, the code above yields: 22355.000 (minor differences when running multiple times). No math conversion that I use makes sense in producing the equivalent Mbps.
Posted
Updated 18-Jul-21 5:30am
v2
Comments
Richard MacCutchan 17-Jul-21 4:00am    
The first thing to ask is what unit is BPS in?

1 solution

Working backwards from the numbers that you give, we get 1 block = 100Mb / 22355 = 4473 bits. This looks close to a 4 Kb (i.e. 512 byte) block size. Adding various header and framing bits make the correspondence even better.

I expect that you are reading blocks of 512 bytes from the remote site, and the BPS is given in those units.
 
Share this answer
 
Comments
wifinut 18-Jul-21 23:34pm    
Thanks Daniel. I was confused by the conversion method but your explanation made it clearer. 👍

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900