Last active
March 1, 2017 08:02
-
-
Save vovanmix/de168bb861ab1b5666e7722ba3a74388 to your computer and use it in GitHub Desktop.
Simple curl benchmark
This file contains 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 | |
URL="$1" | |
MAX_RUNS="$2" | |
SUM_TIME="0" | |
SUM_SIZE="0" | |
i="0" | |
while [ $i -lt $MAX_RUNS ]; do | |
TIME=`curl $URL -o /dev/null -s -w %{time_total}` | |
TIME="${TIME/,/.}" | |
SIZE=`curl $URL -o /dev/null -s -w %{size_download}` | |
SIZE="${SIZE/,/.}" | |
SUM_TIME=`echo "scale=5; $TIME + $SUM_TIME" | bc` | |
SUM_SIZE=`echo "scale=5; $SIZE + $SUM_SIZE" | bc` | |
i=$[$i+1] | |
done | |
TIME_AVERAGE=`echo "scale=5; $SUM_TIME / $MAX_RUNS * 1000" | bc` | |
SIZE_AVERAGE=`echo "scale=5; $SUM_SIZE / $MAX_RUNS / 1024" | bc` | |
echo "Time:" | |
echo "Sum: $SUM_TIME sec" | |
echo "Avg: $TIME_AVERAGE ms" | |
echo "Size:" | |
echo "Sum: $SUM_SIZE b" | |
echo "Avg: $SIZE_AVERAGE kb" | |
#./benchmark.sh http://localhost:80 1000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment