Last active
August 29, 2015 13:56
-
-
Save imzjy/9065119 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/sh | |
#set -x | |
TMP_TXT="$(mktemp)" | |
STAT_TXT="$(mktemp)" | |
cleanup() | |
# cleanup the tmp data when exit by CTRL+C | |
{ | |
echo -en "cleaning up the $TMP_TXT and $STAT_TXT.\ncurrent location:" | |
pwd | |
rm -f $TMP_TXT | |
rm -f $STAT_TXT | |
echo "finished!" | |
exit $? | |
} | |
# register the trap for CTRL+C | |
trap cleanup SIGINT | |
for j in {1..10000}; do | |
# request the resource | |
for i in {1..10}; do | |
curl \ | |
--silent \ | |
--insecure \ | |
--write-out "time_total:%{time_total}\n" \ | |
--cookie "ck=xxxxx" \ | |
https://api.gridgazer.com/studies/ST29efOXdB \ | |
--output "$TMP_TXT" \ | |
>> $STAT_TXT ; echo -n ". " | |
done | |
# statistics | |
echo "" #put a newline | |
echo "the $(( $j * 10 )) times load test:" | |
cat $STAT_TXT | awk -F : '{sum+=$2} END {print " Avg: ", sum/NR}' | |
cat $STAT_TXT | awk -F : 'BEGIN {max =0} {if($2>max) max=$2} END {print " Max: ", max}' | |
cat $STAT_TXT | awk -F : 'BEGIN {min =1999999} {if($2<min) min=$2} END {print " Min: ", min}' | |
echo "TOP 3 of statistics:" | |
sort -t ':' -rn -k2 $STAT_TXT | head -3 | awk -F : '{print " ", $2}' | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment