feat: compact bandwodth

This commit is contained in:
Abhishek Keshri 2023-03-29 15:05:00 +05:30
parent de0e8225a6
commit 4486f2d02c
No known key found for this signature in database
GPG key ID: 62BD6AA2E913B3D3

View file

@ -50,25 +50,25 @@ main() {
total_upload_bps=$(expr "$final_upload" - "$initial_upload")
if [ "$total_download_bps" -gt 1073741824 ]; then
output_download=$(echo "$total_download_bps 1024" | awk '{printf "%.2f \n", $1/($2 * $2 * $2)}')
output_download_unit="gB/s"
output_download=$(echo "$total_download_bps 1024" | awk '{printf "%.1f \n", $1/($2 * $2 * $2)}')
output_download_unit="G"
elif [ "$total_download_bps" -gt 1048576 ]; then
output_download=$(echo "$total_download_bps 1024" | awk '{printf "%.2f \n", $1/($2 * $2)}')
output_download_unit="mB/s"
output_download=$(echo "$total_download_bps 1024" | awk '{printf "%.1f \n", $1/($2 * $2)}')
output_download_unit="M"
else
output_download=$(echo "$total_download_bps 1024" | awk '{printf "%.2f \n", $1/$2}')
output_download_unit="kB/s"
output_download=$(echo "$total_download_bps 1024" | awk '{printf "%.1f \n", $1/$2}')
output_download_unit="K"
fi
if [ "$total_upload_bps" -gt 1073741824 ]; then
output_upload=$(echo "$total_download_bps 1024" | awk '{printf "%.2f \n", $1/($2 * $2 * $2)}')
output_upload_unit="gB/s"
output_upload=$(echo "$total_download_bps 1024" | awk '{printf "%.1f \n", $1/($2 * $2 * $2)}')
output_upload_unit="G"
elif [ "$total_upload_bps" -gt 1048576 ]; then
output_upload=$(echo "$total_upload_bps 1024" | awk '{printf "%.2f \n", $1/($2 * $2)}')
output_upload_unit="mB/s"
output_upload=$(echo "$total_upload_bps 1024" | awk '{printf "%.1f \n", $1/($2 * $2)}')
output_upload_unit="M"
else
output_upload=$(echo "$total_upload_bps 1024" | awk '{printf "%.2f \n", $1/$2}')
output_upload_unit="kB/s"
output_upload=$(echo "$total_upload_bps 1024" | awk '{printf "%.1f \n", $1/$2}')
output_upload_unit="K"
fi
echo "$output_download$output_download_unit•↑ $output_upload$output_upload_unit"