Created
January 19, 2017 16:00
-
-
Save LadyNamedLaura/eb5d1dd7326d02ea4322970e84fb6a4f to your computer and use it in GitHub Desktop.
little website latency test script
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/bash | |
function join_by { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; } | |
export LC_ALL=C | |
urls=("$@") | |
data="$(mktemp)" | |
exec 5> >(gnuplot) | |
cat >&5 << EOF | |
set terminal x11 | |
set grid y | |
set xlabel 'request' | |
set ylabel 'response' | |
EOF | |
echo "time" > "${data}" | |
plotline=() | |
for i in "${!urls[@]}"; do | |
echo -ne "\"${urls[$i]}\"\t" >> "${data}" | |
idx=$(( $i + 2 )) | |
plotline[$i]="\"${data}\" using $idx:xticlabels(1) smooth sbezier with lines title \"${urls[$i]}\"" | |
done | |
echo '' >> "${data}" | |
plotline="plot $(join_by ', ' "${plotline[@]}")" | |
while true | |
do | |
now="$(date +%X)" | |
echo -n "\"$now\"" >> "${data}" | |
for url in "${urls[@]}" | |
do | |
t=$(curl -o /dev/null -s -w %{time_total} $url) | |
t=$( echo "$t * 1000 " | bc) | |
echo -ne "\t$t" >> "${data}" | |
done | |
echo "" >> "${data}" | |
echo $plotline >&5 | |
sleep .5 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment