-
-
Save xarg/f6970175a6eedbca2024 to your computer and use it in GitHub Desktop.
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
#!/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 "# Let's output to a jpeg file | |
set terminal jpeg size 1280,720 | |
# This sets the aspect ratio of the graph | |
set size 1, 1 | |
# The file we'll write to | |
set output 'benchmark_${1}_${2}.png' | |
# The graph title | |
set title 'Benchmark: ${1} ${2}' | |
# Where to place the legend/key | |
set key left top | |
# Draw gridlines oriented on the y axis | |
set grid y | |
# Specify that the x-series data is time data | |
set xdata time | |
# Specify the *input* format of the time data | |
set timefmt '%s' | |
# Specify the *output* format for the x-axis tick labels | |
set format x '%S' | |
# Label the x-axis | |
set xlabel 'seconds' | |
# Label the y-axis | |
set ylabel 'response time (ms)' | |
set datafile separator '\\t'" > /tmp/plotme | |
## 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 -g "gnuplot_${c}.out" "${var}" | |
## if for concat stuff | |
if [ $c -gt 3 ] | |
then | |
echo -e ", 'gnuplot_${c}.out' every ::2 using 2:5 title '${var}' with points\\" >> /tmp/plotme | |
else | |
echo -e "plot 'gnuplot_${c}.out' every ::2 using 2:5 title '${var}' with points\\" >> /tmp/plotme | |
fi | |
fi | |
let c++ | |
done | |
## plotting | |
gnuplot /tmp/plotme | |
echo -e "\n Success! Result image is: benchmark_${1}_${2}.png" | |
## show the image | |
open benchmark_${1}_${2}.png > /dev/null & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment