Last active
January 14, 2024 23:21
-
-
Save garethrees/7356890 to your computer and use it in GitHub Desktop.
Graphing apache benchmark results with gnuplot
This file contains hidden or 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
# Output to a jpeg file | |
set terminal jpeg size 1280,720 | |
# Set the aspect ratio of the graph | |
set size 1, 1 | |
# The file to write to | |
set output "timeseries.jpg" | |
# The graph title | |
set title "Benchmark testing" | |
# 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)" | |
# Tell gnuplot to use tabs as the delimiter instead of spaces (default) | |
set datafile separator '\t' | |
# Plot the data | |
plot "out.dat" every ::2 using 2:5 title 'response time' with points |
This file contains hidden or 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
$ ab -n 1000 -c 10 -g out.dat http://example.com/ |
I suggest you rescale x time value to 0 using the following command at the beginning (nb 'set data separator' has been moved to the beginning)
# Tell gnuplot to use tabs as the delimiter instead of spaces (default)
set datafile separator '\t'
# First stats file to extract min time value
# (must be done before setting that x will be a time data series)
stats "out.dat" every ::2 using 2 prefix "A"
and a final plot using
# Plot the data with an x-origin at 0
plot "out.dat" every ::2 using ($2-A_min):5 title 'response time' with points
I suggest another proposal to counter-balance not ordered in ab data.
# Tell gnuplot to use tabs as the delimiter instead of spaces (default)
set datafile separator '\t'
# output as png image
set terminal png
# save file to "benchmark.png"
set output "benchmark.png"
# The graph title
set title "HTTP Benchmark"
# Where to place the legend/key
set key right bottom
# x-axis label
set xlabel "seconds"
set grid x
set logscale x
# y-axis label
set ylabel "% of completed requests"
set grid y
set format y '%2.0f%%'
stats "out.dat" every ::2 using 5 prefix "A"
# data must be sort according to their value (default order has a bias due to late request are obviously long)
# column 9 in sort is equivalent to 5 with a tabulated separated data
plot '<(tail -n +2 out.dat | sort -n -k 9)' every ::2 using 5:(100*$0/A_records) smooth sbezier with lines t '% of request done before time'
Seconds are not looking ok
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Update http://www.bradlanders.com/2013/04/15/apache-bench-and-gnuplot-youre-probably-doing-it-wrong/