Notes and anecdotes

Techstuff rambling

Quick http benchmarking with curl

From time to time, I’d like to see how the performance gain/loss was after a code change. Say I’ve updated locahost:8000/search and I’d like to do 100 http calls to localhost:8000/search?q=fish to see how it performs:

Gist at

  1. Save the file below as

echo "Running $iterations iterations for curl $url"

for run in $(seq 1 $iterations)
 time=$(curl $url -s -o /dev/null -w "%{time_starttransfer}\n")
 totaltime=$(echo "$totaltime" + "$time" | bc)

avgtimeMs=$(echo "scale=4; 1000*$totaltime/$iterations" | bc)

echo "Averaged $avgtimeMs ms in $iterations iterations"

2. Run with the following command

sh 10

3. Output

Running 10 iterations for curl
Averaged 88.0227 ms in 10 iterations

tomfa • 2018-11-15

Previous Post