Last active
September 9, 2015 00:47
-
-
Save hyamamoto/cbc952c06bc45e12bdcf to your computer and use it in GitHub Desktop.
A little dirty HTTP benchmark script that was on my ancient disk. ab_hammer.sh uses ab (Apache Benchmark) to hammer the ${target_url} ${attempt} times with (${scale} * 10) concurrency requests, then spits the benchmark result to "${title}-X.csv" and "${title}.csv" .
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
#!/bin/bash | |
# A little dirty HTTP benchmark script | |
# | |
# ab_hammer.sh uses ab (Apache Benchmark) to hammer the ${target_url} ${attempt} times | |
# with (${scale} * 10) concurrency requests, then spits the benchmark result to | |
# "${title}-X.csv" and "${title}.csv" . | |
title=hammer | |
target_url="http://www.yourtarget_here.com/" | |
# will hammer the server until it reaches (scale * 10) concurrent requests. | |
scale=1 | |
attempt=3000 | |
# Hammer | |
echo "Start Hammering." | |
for idx in `seq 1 1 ${scale}` | |
do | |
for sub_idx in `seq 1 1 5` | |
do | |
ab -n ${attempt} -c ${idx}0 ${target_url} | tee ${title}-${idx}-${sub_idx}.log | |
done | |
done | |
echo "Done Hammering." | |
# Summerize | |
resultfile=${title}.csv | |
> $resultfile | |
for idx in `seq 1 1 ${scale}` | |
do | |
section=${title}-${idx} | |
resultfile_section=${section}.csv | |
echo $section > tmp.log; echo $section >> tmp.log; echo $section >> tmp.log; echo $section >> tmp.log | |
cat tmp.log > $resultfile_section | |
rm tmp.log | |
for sub_idx in `seq 1 1 5` | |
do | |
subsection="${section}-${sub_idx}" | |
logfile=${subsection}.log | |
cat $logfile | sed -n 's/.*Failed requests: *\([0-9\.]*\).*/\1/p' > tmp.log | |
cat $logfile | sed -n 's/.*Requests per second: *\([0-9\.]*\) \[#\/sec\] (mean).*/\1/p' >> tmp.log | |
cat $logfile | sed -n 's/.*request: *\([0-9\.]*\) \[ms] (mean,.*/\1/p' >> tmp.log | |
cat $logfile | sed -n 's/.*request: *\([0-9\.]*\) \[ms] (mean).*/\1/p' >> tmp.log | |
paste -d, $resultfile_section tmp.log > tmp2.log | |
rm tmp.log | |
mv tmp2.log $resultfile_section | |
done | |
echo "Created file [$resultfile_section]." | |
cat $resultfile_section >> $resultfile | |
done | |
echo "Created file [$resultfile]." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment