Class: AbCrunch::AbResult
- Inherits:
-
Object
- Object
- AbCrunch::AbResult
- Defined in:
- lib/abcrunch/ab_result.rb
Instance Attribute Summary collapse
-
#ab_options ⇒ Object
Returns the value of attribute ab_options.
-
#raw ⇒ Object
Returns the value of attribute raw.
Instance Method Summary collapse
- #avg_response_time ⇒ Object
- #command ⇒ Object
- #failed_requests ⇒ Object
-
#initialize(raw_ab_output, ab_options) ⇒ AbResult
constructor
A new instance of AbResult.
- #log ⇒ Object
- #queries_per_second ⇒ Object
Constructor Details
#initialize(raw_ab_output, ab_options) ⇒ AbResult
Returns a new instance of AbResult.
5 6 7 8 |
# File 'lib/abcrunch/ab_result.rb', line 5 def initialize(raw_ab_output, ) @raw = raw_ab_output @ab_options = end |
Instance Attribute Details
#ab_options ⇒ Object
Returns the value of attribute ab_options.
3 4 5 |
# File 'lib/abcrunch/ab_result.rb', line 3 def @ab_options end |
#raw ⇒ Object
Returns the value of attribute raw.
3 4 5 |
# File 'lib/abcrunch/ab_result.rb', line 3 def raw @raw end |
Instance Method Details
#avg_response_time ⇒ Object
14 15 16 |
# File 'lib/abcrunch/ab_result.rb', line 14 def avg_response_time raw.match(/Time per request:\s*([\d\.]+)\s\[ms\]\s\(mean\)/)[1].to_f end |
#command ⇒ Object
10 11 12 |
# File 'lib/abcrunch/ab_result.rb', line 10 def command AbCrunch::AbRunner.ab_command(@ab_options) end |
#failed_requests ⇒ Object
22 23 24 |
# File 'lib/abcrunch/ab_result.rb', line 22 def failed_requests raw.match(/Failed requests:\s*([\d\.]+)/)[1].to_i end |
#log ⇒ Object
26 27 28 29 30 31 |
# File 'lib/abcrunch/ab_result.rb', line 26 def log AbCrunch::Logger.log :ab_result, "#{command}" AbCrunch::Logger.log :ab_result, "Average Response Time: #{avg_response_time}" AbCrunch::Logger.log :ab_result, "Queries per Second: #{queries_per_second}" AbCrunch::Logger.log :ab_result, "Failed requests: #{failed_requests}" end |
#queries_per_second ⇒ Object
18 19 20 |
# File 'lib/abcrunch/ab_result.rb', line 18 def queries_per_second raw.match(/Requests per second:\s*([\d\.]+)\s\[#\/sec\]\s\(mean\)/)[1].to_f end |