Skip to content

Instantly share code, notes, and snippets.

@IslamAzab
Forked from emersonmoretto/benchmark.sh
Last active September 7, 2015 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IslamAzab/256393d714662e94f570 to your computer and use it in GitHub Desktop.
Save IslamAzab/256393d714662e94f570 to your computer and use it in GitHub Desktop.
Apache bench + Gnuplot Script
#!/bin/bash
echo -e "\nbenchmark.sh -n<number of requests> -c<number of concurrency> <URL1> <URL2> ..."
echo -e "\nEx: benchmark.sh -n100 -c10 http://www.google.com/ http://www.bing.com/ \n"
## Gnuplot settings
echo "set terminal jpeg
set output 'benchmark_${1}_${2}.jpeg'
set title 'Benchmark: ${1} ${2}'
set size 1,1
set grid y
set xlabel 'request'
set ylabel 'response time (ms)'" > /tmp/plotme
# set terminal jpeg
# set output 'benchmark_${1}_${2}.jpeg'
# set title 'Benchmark: ${1} ${2}'
# set size 1,1
# set grid y
# set timefmt '%s'
# set format x '%S'
# set xlabel 'seconds'
# set ylabel 'response time (ms)
## Loop over parameters
c=1
for var in "$@"
do
## skipping first parameters (concurrency and requests)
if [ $c -gt 2 ]
then
## apache-bench
ab $1 $2 -r -g "gnuplot_${c}.out" "${var}"
## if for concat stuff
if [ $c -gt 3 ]
then
echo -e ", 'gnuplot_${c}.out' using 9 smooth sbezier with lines title '${var}' \\" >> /tmp/plotme
else
echo -e "plot 'gnuplot_${c}.out' using 9 smooth sbezier with lines title '${var}' \\" >> /tmp/plotme
fi
fi
let c++
done
## plotting
gnuplot /tmp/plotme
echo -e "\n Success! Result image is: benchmark_${1}_${2}.jpeg"
## show the image
eog benchmark_${1}_${2}.jpeg > /dev/null &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment