Created
August 29, 2019 13:41
-
-
Save pixmin/588e381743634f579bd4e0891e60cdde to your computer and use it in GitHub Desktop.
Time to load page
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 | |
# To decide how many times the test should be run: | |
# perf <n> <url> | |
# | |
# Otherwise simply use | |
# perf <url> | |
DEFAULT_RUN=10 | |
if [[ $1 =~ ^-?[0-9]+$ ]] | |
then | |
COUNT=$1 | |
URL=$2 | |
else | |
COUNT=$DEFAULT_RUN | |
URL=$1 | |
fi | |
TOTAL=0 | |
for ((i=1;i<=COUNT;i++)) | |
do | |
TIME=`curl -w "%{time_total}\n" -o /dev/null -s "$URL"` | |
TOTAL=`echo $TOTAL + $TIME | bc` | |
echo $TIME | |
done | |
# Int | |
# AVERAGE=$(echo "$TOTAL / $COUNT" | bc) | |
# Float | |
AVERAGE=$(awk "BEGIN {printf \"%.4f\",${TOTAL}/${COUNT}}") | |
echo -e "\nAverage after $COUNT runs: $AVERAGE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment