Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 9th, 2012  |  syntax: None  |  size: 1.03 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash
  2.  
  3. echo -e "\nbenchmark.sh -n<number of requests> -c<number of concurrency> <URL1> <URL2> ..."
  4.  
  5. echo -e "\nEx: benchmark.sh -n100 -c10 http://www.google.com/ http://www.bing.com/ \n"
  6.  
  7. ## Gnuplot settings
  8. echo "set terminal png
  9. set output 'benchmark_${1}_${2}.png'
  10. set title 'Benchmark: ${1} ${2}'
  11. set size 1,1
  12. set grid y
  13. set xlabel 'request'
  14. set ylabel 'response time (ms)' " > /tmp/plotme
  15.  
  16.  
  17. ## Loop over parameters
  18. c=1
  19. for var in "$@"
  20. do
  21.        
  22.     ## skipping first parameters (concurrency and requests)
  23.     if [ $c -gt 2 ]  
  24.     then
  25.  
  26.         ## apache-bench
  27.         ab $1 $2 -g "gnuplot_${c}.out" "${var}"
  28.        
  29.         ## if for concat stuff
  30.         if [ $c -gt 3 ]  
  31.         then
  32.                 echo -e ", 'gnuplot_${c}.out' using 9 smooth sbezier with lines title '${var}' \\" >> /tmp/plotme
  33.         else
  34.                 echo -e "plot 'gnuplot_${c}.out' using 9 smooth sbezier with lines title '${var}' \\" >> /tmp/plotme
  35.         fi
  36.     fi
  37.  
  38.     let c++
  39. done
  40.  
  41. ## plotting
  42. gnuplot /tmp/plotme
  43.  
  44. echo -e "\n Success! Result image is: benchmark_${1}_${2}.png"
  45.  
  46. ## show the image
  47. eog benchmark_${1}_${2}.png > /dev/null &