Class: BenchTool::ABCmdBuilder
- Inherits:
-
Object
- Object
- BenchTool::ABCmdBuilder
- Defined in:
- lib/benchtool/ab-cmd-builder.rb
Instance Method Summary collapse
-
#initialize(params, options = {}) ⇒ ABCmdBuilder
constructor
A new instance of ABCmdBuilder.
- #to_str ⇒ Object
Constructor Details
#initialize(params, options = {}) ⇒ ABCmdBuilder
Returns a new instance of ABCmdBuilder.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/benchtool/ab-cmd-builder.rb', line 4 def initialize(params, = {}) @params = params @options = # Sample ab cmd # ab -n #{requests} -c #{concurrency} -g '#{plotfile}' -C '#{cookies}' -H '#{header}' '#{url}' @parts = { :base => "ab ", :requests => "-n %s ", :concurrency => "-c %s ", :plotfile => "-g '%s' ", :cookies => "-C '%s' ", :header => "-H '%s' ", :url => "'%s'", } end |
Instance Method Details
#to_str ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/benchtool/ab-cmd-builder.rb', line 20 def to_str cmd = "" cmd << @parts[:base] cmd << @parts[:requests] % @params[:requests] cmd << @parts[:concurrency] % @params[:concurrency] cmd << @parts[:plotfile] % @params[:plotfile] unless @options[:no_plotfile] == false cmd << @parts[:cookies] % @params[:cookies] unless @params[:headers].empty? @params[:headers].each do |header| cmd << @parts[:header] % header end end cmd << @parts[:url] % @params[:url] end |