Class: AbCrunch::AbRunner
- Inherits:
-
Object
- Object
- AbCrunch::AbRunner
- Defined in:
- lib/abcrunch/ab_runner.rb
Class Method Summary collapse
Class Method Details
.ab(options) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/abcrunch/ab_runner.rb', line 18 def self.ab() cmd = ab_command() result = nil Open3.popen3(cmd) do |stdin, stdout, stderr| err_lines = stderr.readlines if err_lines.length > 0 cmd = cmd.cyan err = "AB command failed".red err_s = err_lines.reduce {|line, memo| memo += line}.red raise "#{err}\nCommand: #{cmd}\n#{err_s}" end result = AbCrunch::AbResult.new stdout.readlines.reduce {|line, memo| memo += line}, end result end |
.ab_command(options) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/abcrunch/ab_runner.rb', line 11 def self.ab_command() = () url = AbCrunch::Page.get_url(, true) AbCrunch::Logger.log(:info, "Calling ab on: #{url}") "ab -c #{options[:concurrency]} -n #{options[:num_requests]} -k -H 'Accept-Encoding: gzip' #{url}" end |
.validate_options(options) ⇒ Object
6 7 8 9 |
# File 'lib/abcrunch/ab_runner.rb', line 6 def self.() raise "AB Options missing :url" unless .has_key? :url AbCrunch::Config..merge() end |