Skip to content

Instantly share code, notes, and snippets.

@nnnnathann
Created July 15, 2013 19:05
Show Gist options
  • Save nnnnathann/6002504 to your computer and use it in GitHub Desktop.
Save nnnnathann/6002504 to your computer and use it in GitHub Desktop.
cURL TIming
#!/bin/bash
URL="$1"
DATA="$2"
MAX_RUNS="$3"
SUM_TIME="0"
i="0"
while [ $i -lt $MAX_RUNS ]; do
TIME=`curl $URL -d $DATA -o /dev/null -s -w %{time_total}`
TIME="${TIME/,/.}"
SUM_TIME=`echo "scale=5; $TIME + $SUM_TIME" | bc`
i=$[$i+1]
done
TIME_AVERAGE=`echo "scale=5; $SUM_TIME / $MAX_RUNS" | bc`
echo "Sum: $SUM_TIME"
echo "Avg: $TIME_AVERAGE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment