#!/bin/bash # Runs ApacheBench a preset number of times and outputs the mean request time as CSV # # Bryant Casteel # http://bethings.postplatinum.com/tag/ab-time-chart/ # 2010-12-05 # configuration MIN_CONNECTIONS=1 MAX_CONNECTIONS=400 SAMPLES=100 # output the column headings echo -n '""' for url in $*; do echo -n ',"'"$url"'"' done echo # output row of zeroes for origin echo -n '0' for url in $*; do echo -n ',0' done echo # for increasing number of concurrent connections interval=1 connections=$MIN_CONNECTIONS while (( connections <= MAX_CONNECTIONS )); do # output the row heading echo -n "$connections" # test each URL (( hits = ( connections * SAMPLES ) )) for url in $*; do mean_time=`ab -n $hits -c $connections "$url" | grep 'Time per request.*(mean)' \ | cut -c25- | sed 's/^\([0-9\.]\+\).*$/\1/'` echo -n ",$mean_time" done # end the row echo # calculate next increment if (( ( connections / (interval * 10) ) >= 1 )); then # increment the connections by increasing powers of 10 (( interval = (interval * 10) )) fi (( connections = ( connections + interval) )) done