Skip to content

Instantly share code, notes, and snippets.

@blessani
Created November 3, 2015 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blessani/7899db87a5d0a068aa09 to your computer and use it in GitHub Desktop.
Save blessani/7899db87a5d0a068aa09 to your computer and use it in GitHub Desktop.
avg_curl
avg_curl ()
{
TOTAL_RUNS=3;
TIMEFORMAT=%R;
TOTAL_TIME=0;
for i in $(seq 1 $TOTAL_RUNS);
do
LOAD_TIME=$( (time curl -s -o /dev/null "$1") 2>&1 );
TOTAL_TIME=$( echo "scale=3; $TOTAL_TIME + $LOAD_TIME" | bc -l );
done;
echo "scale=3; $TOTAL_TIME / $TOTAL_RUNS" | bc -l | awk '{printf "%.3f\n", $0}'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment