Skip to content

Instantly share code, notes, and snippets.

@koniu
Last active March 11, 2018 16:36
Show Gist options
  • Save koniu/7a0593f8d09b324b582c1930fd0e9671 to your computer and use it in GitHub Desktop.
Save koniu/7a0593f8d09b324b582c1930fd0e9671 to your computer and use it in GitHub Desktop.
icecast test script
#!/bin/bash
#
# run concurrent curls which download from URL to /dev/null. output total
# and average counts to results directory.
#
# url to request from
URL="$1"
# max concurrent curls to kick off
conn="$2"
# how long to sleep between each curl, can be decimal 0.5
duration=$3
# how long to stay connected (in seconds)
delay=$4
[ $# -lt 3 ] && {
echo "Usage: $0 <url> <#connections> <duration> [delay]"
exit 127
}
test() {
read size speed conntime rescode exitcode <<< \
"$(curl -o /dev/null -m $duration -s -w \
"%{size_download} %{speed_download} %{time_starttransfer} %{http_code} "\
"$URL"; echo $?)"
speed=$(echo "scale=1; $speed / 1024" | bc)
size=$(echo "scale=2; $size/ 1024" | bc)
printf "#%s | %s | %-10s | %-10s | %s\n"\
"$count$count2"\
"$rescode"\
"$size kB"\
"$speed kB/s"\
"$conntime s"
}
echo "<<< Testing icecast >>>
date: $(date -R)
url: $URL
conns: ${conn}
timeout: ${duration}s
delay : ${delay}s
"
#count=0
for count in `seq -w 0 $[ ($conn - 1) / 10 ]`
do
for count2 in `seq 0 9`; do test & done
[ "$delay" != "" ] && sleep $delay
done
wait
echo
echo "done"
<<< Testing icecast >>>
date: Sun, 19 Jun 2016 00:19:35 +0100
url: http://radiotest/mpd.ogg
conns: 99
timeout: 120s
delay : 10s
#07 | HTTP 200 | 401.07 kB | 3.3 kB/s | 0.976 s
#00 | HTTP 200 | 401.07 kB | 3.3 kB/s | 0.938 s
#02 | HTTP 200 | 401.07 kB | 3.3 kB/s | 0.911 s
#04 | HTTP 200 | 401.07 kB | 3.3 kB/s | 0.947 s
#05 | HTTP 200 | 401.07 kB | 3.3 kB/s | 0.934 s
#01 | HTTP 200 | 401.07 kB | 3.3 kB/s | 0.935 s
#06 | HTTP 200 | 399.08 kB | 3.3 kB/s | 0.970 s
#09 | HTTP 200 | 401.07 kB | 3.3 kB/s | 0.967 s
#08 | HTTP 200 | 399.08 kB | 3.3 kB/s | 0.987 s
#03 | HTTP 200 | 401.07 kB | 3.3 kB/s | 0.952 s
#10 | HTTP 200 | 361.75 kB | 3.0 kB/s | 0.558 s
#17 | HTTP 200 | 361.75 kB | 3.0 kB/s | 0.581 s
#11 | HTTP 200 | 361.75 kB | 3.0 kB/s | 0.588 s
#13 | HTTP 200 | 361.75 kB | 3.0 kB/s | 0.570 s
#18 | HTTP 200 | 361.75 kB | 3.0 kB/s | 0.577 s
#14 | HTTP 200 | 361.75 kB | 3.0 kB/s | 0.582 s
#16 | HTTP 200 | 361.75 kB | 3.0 kB/s | 0.583 s
#19 | HTTP 200 | 361.75 kB | 3.0 kB/s | 0.586 s
#15 | HTTP 200 | 368.61 kB | 3.0 kB/s | 0.584 s
#12 | HTTP 200 | 368.61 kB | 3.0 kB/s | 0.583 s
#21 | HTTP 200 | 469.16 kB | 3.9 kB/s | 0.804 s
#20 | HTTP 200 | 449.37 kB | 3.7 kB/s | 0.793 s
#24 | HTTP 200 | 457.85 kB | 3.8 kB/s | 0.784 s
#26 | HTTP 200 | 332.00 kB | 2.7 kB/s | 0.796 s
#27 | HTTP 200 | 412.00 kB | 3.4 kB/s | 0.778 s
#25 | HTTP 200 | 381.49 kB | 3.1 kB/s | 0.806 s
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment