Created
September 8, 2017 16:44
-
-
Save hiroshiro/ca043a30dc143c05c27fe5af9825d96e to your computer and use it in GitHub Desktop.
speed test by ping
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function lan_speed | |
set -l host $argv[1] | |
echo 'host ' $host | |
set -l size $argv[2] | |
echo 'size ' $size | |
set -l count $argv[3] | |
echo 'count ' $count | |
set -l datasize (math $size'*2') | |
echo 'datasize ' $datasize | |
set -l pings 'sudo ping -c '$count' -s '$size' '$host' | grep avg | cut -d\/ -f5' | |
echo 'pingcmd '$pings | |
set -l timems (eval $pings) | |
echo 'timems '$timems 'ms' | |
set -l time (math -s6 $timems'/1000') | |
echo 'time 0'$time 's' | |
set -l byteps (math -s6 $datasize/$time) | |
echo 'Bps ' $byteps 'Bps' | |
set -l bps (math $byteps'*8') | |
echo 'bps ' $bps 'bps' | |
set -l kBps (math -s3 $byteps'/1024') | |
echo 'kBps ' $kBps 'kBps' | |
set -l MBps (math -s3 $kBps'/1024') | |
echo 'MBps ' $MBps 'MBps' | |
set -l kbps (math -s3 $kBps'*8') | |
echo 'kbps ' $kbps 'kbps' | |
set -l Mbps (math -s3 $MBps'*8') | |
echo 'Mbps ' $Mbps 'Mbps' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment