Skip to content

Instantly share code, notes, and snippets.

@bosky101
Forked from emersonmoretto/benchmark.sh
Last active August 29, 2015 13:58
Show Gist options
  • Save bosky101/10227730 to your computer and use it in GitHub Desktop.
Save bosky101/10227730 to your computer and use it in GitHub Desktop.
benchmark a bunch of urls with POST and plot them in the same graph as points
#!/bin/bash
echo -e "\nbenchmark.sh <title> -n<number of requests> -c<number of concurrency> <URL1> <URL2> ..."
echo -e "\nEx: benchmark.sh example -n100 -c10 http://www.google.com/ http://www.bing.com/ will create benchmar-example-n100-c10.png\n"
## Gnuplot settings
echo "set terminal png
set output 'benchmark-${1}${2}${3}.png'
set title 'Benchmark: ${1} with ab ${2} ${3}'
set size 1,1
set grid y
set xlabel 'requests'
set ylabel 'response time (ms)' " > /tmp/plotme
## Loop over parameters
c=1
for var in "$@"
do
## skipping first parameters (concurrency and requests)
if [ $c -gt 3 ]
then
## apache-bench
ab $2 $3 -p post.json -g "gnuplot_${c}.out" "${var}"
## if for concat stuff
if [ $c -gt 4 ]
then
echo -e ", 'gnuplot_${c}.out' using 9 smooth sbezier with points title '${var}' \\" >> /tmp/plotme
else
echo -e "plot 'gnuplot_${c}.out' using 9 smooth sbezier with points title '${var}' \\" >> /tmp/plotme
fi
fi
let c++
done
## plotting
gnuplot /tmp/plotme
echo -e "\n Success! Result image is: benchmark-${1}${2}${3}.png"
event={
"xx" : "xxxxxx",
"yy" : "xxxxxx",
"z" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"a" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"bb" : "xxx",
"c" : "xxx",
"d" : "xxxxx"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment