Last active
December 1, 2018 11:01
-
-
Save tomfa/2509a9a6695462df928d7fe30c25d787 to your computer and use it in GitHub Desktop.
Simple curl benchmarking - http://notes.webutvikling.org/quick-http-benchmarking-with-curl/
This file contains 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
# Simple curl benchmarking | |
# | |
# Example: 10 (sequential) calls towards google.com | |
# sh benchmark.sh 10 http://google.com | |
# | |
# Output: | |
# Running 10 iterations for curl https://google.com | |
# ..... | |
# Averaged 63.8024 ms in 10 iterations | |
#!/bin/sh | |
iterations=$1 | |
url=$2 | |
echo "Running $iterations iterations for curl $url" | |
totaltime=0.0 | |
for run in $(seq 1 $iterations) | |
do | |
time=$(curl $url -s -o /dev/null -w "%{time_starttransfer}\n") | |
totaltime=$(echo "$totaltime" + "$time" | bc) | |
done | |
avgtimeMs=$(echo "scale=4; 1000*$totaltime/$iterations" | bc) | |
echo "Averaged $avgtimeMs ms in $iterations iterations" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment