-
-
Save bugcy013/761250cd02b900a54ea0 to your computer and use it in GitHub Desktop.
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
| #!/bin/bash -e | |
| # Little program that measure the speed in MBps of a file transfer occuring in the current directory | |
| LASTTIME=$(date +%s) | |
| LASTSIZE=$(du -bs . 2> /dev/null | awk '{ print $1 }') | |
| TOTALSIZE=0 | |
| TOTALTIME=0 | |
| while true | |
| do | |
| TIME=$(date +%s) | |
| SIZE=$(du -bs . 2> /dev/null | awk '{ print $1 }') | |
| ELAPSED=$((${TIME}-${LASTTIME})) | |
| SIZECHANGE=$((${SIZE}-${LASTSIZE})) | |
| TOTALSIZE=$((${TOTALSIZE}+${SIZECHANGE})) | |
| TOTALTIME=$((${TOTALTIME} + ${ELAPSED})) | |
| echo | awk -v tsz=${TOTALSIZE} -v tt=${TOTALTIME} '{ if (tt > 0) { printf "%.2f MBps\n", tsz/1024/1024/tt } }' | |
| LASTSIZE=${SIZE} | |
| LASTTIME=${TIME} | |
| sleep 2 | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment