commit 0b339c47a2100ba929c04573c956d6b7c40f81c6 Author: Oliver Ladner Date: Mon Feb 19 13:45:34 2024 +0100 add WIP state diff --git a/README.md b/README.md new file mode 100644 index 0000000..2a54ca3 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# ab (apache bench) and Gnuplot +Two scripts: + +* `ab.sh` runs your ab benchmark. Specifiy requests, concurrency and URL +* `plot_ttime.sh` generates graphs with Gnuplot (total time) +* `plot_ttfb.sh` generates graphs with Gnuplot (Time To First Byte) + +Web links: + +* [Apache Bench and Gnuplot: you’re probably doing it wrong](http://www.bradlanders.com/2013/04/15/apache-bench-and-gnuplot-youre-probably-doing-it-wrong/) diff --git a/ab.sh b/ab.sh new file mode 100755 index 0000000..532b890 --- /dev/null +++ b/ab.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +reqs=100000 +concurrency=10 +url='https://example.org' +fileprefix='example_org' +useragent="Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1 apachebench" + +# apache bench with basic authentication +ab -A username:password -H "User-Agent: $useragent" -n $reqs -c $concurrency -g ${fileprefix}_$(date +%F_%H%M%S)_r-${reqs}_c-${concurrency}.gnuplot $url > ${fileprefix}_$(date +%F_%H%M%S)_r-${reqs}_c-${concurrency}.log diff --git a/plot_ttfb.sh b/plot_ttfb.sh new file mode 100755 index 0000000..faa71b6 --- /dev/null +++ b/plot_ttfb.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +for file in $(ls -1 example*\.gnuplot); do + gnuplot <<- EOF + set terminal png size 1280,500 + set size 1, 1 + set output "$file\_ttfb.png" + set title "$file" + set key left top + set grid y + set xdata time + set timefmt "%s" + set format x "%H:%M:%S" + set xlabel 'time' + set ylabel "response time (ms)" + set yrange [0:10000] + set datafile separator '\t' + plot "$file" every ::2 using 2:6 title 'response time (TTFB)' with points + exit + EOF +done diff --git a/plot_ttime.sh b/plot_ttime.sh new file mode 100755 index 0000000..4bdeb2f --- /dev/null +++ b/plot_ttime.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +for file in $(ls -1 example*\.gnuplot); do + gnuplot <<- EOF + set terminal png size 1280,500 + set size 1, 1 + set output "$file\_ttime.png" + set title "$file" + set key left top + set grid y + set xdata time + set timefmt "%s" + set format x "%H:%M:%S" + set xlabel 'time' + set ylabel "response time (ms)" + set yrange [0:10000] + set datafile separator '\t' + plot "$file" every ::2 using 2:5 title 'response time (total)' with points + exit + EOF +done