Class: HanselCore::HttperfResultParser
- Inherits:
-
Object
- Object
- HanselCore::HttperfResultParser
- Defined in:
- lib/hansel/httperf_result_parser.rb
Overview
Parse httperf output.
Instance Attribute Summary collapse
-
#connection_rate ⇒ Object
Returns the value of attribute connection_rate.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#net_io ⇒ Object
Returns the value of attribute net_io.
-
#rate ⇒ Object
Returns the value of attribute rate.
-
#replies ⇒ Object
Returns the value of attribute replies.
-
#reply_rate_avg ⇒ Object
Returns the value of attribute reply_rate_avg.
-
#reply_rate_max ⇒ Object
Returns the value of attribute reply_rate_max.
-
#reply_rate_min ⇒ Object
Returns the value of attribute reply_rate_min.
-
#reply_rate_stddev ⇒ Object
Returns the value of attribute reply_rate_stddev.
-
#reply_time ⇒ Object
Returns the value of attribute reply_time.
-
#request_rate ⇒ Object
Returns the value of attribute request_rate.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(input) ⇒ HttperfResultParser
constructor
A new instance of HttperfResultParser.
- #parse(httperf_result) ⇒ Object
- #parse_connection_rate(line) ⇒ Object
- #parse_errors(line) ⇒ Object
- #parse_line(line) ⇒ Object
- #parse_net_io(line) ⇒ Object
- #parse_replies(line) ⇒ Object
- #parse_reply_rate(line) ⇒ Object
- #parse_reply_time(line) ⇒ Object
- #parse_request_rate(line) ⇒ Object
- #parse_status(line) ⇒ Object
Constructor Details
#initialize(input) ⇒ HttperfResultParser
Returns a new instance of HttperfResultParser.
10 11 12 |
# File 'lib/hansel/httperf_result_parser.rb', line 10 def initialize input @input = input end |
Instance Attribute Details
#connection_rate ⇒ Object
Returns the value of attribute connection_rate.
6 7 8 |
# File 'lib/hansel/httperf_result_parser.rb', line 6 def connection_rate @connection_rate end |
#errors ⇒ Object
Returns the value of attribute errors.
6 7 8 |
# File 'lib/hansel/httperf_result_parser.rb', line 6 def errors @errors end |
#net_io ⇒ Object
Returns the value of attribute net_io.
6 7 8 |
# File 'lib/hansel/httperf_result_parser.rb', line 6 def net_io @net_io end |
#rate ⇒ Object
Returns the value of attribute rate.
6 7 8 |
# File 'lib/hansel/httperf_result_parser.rb', line 6 def rate @rate end |
#replies ⇒ Object
Returns the value of attribute replies.
6 7 8 |
# File 'lib/hansel/httperf_result_parser.rb', line 6 def replies @replies end |
#reply_rate_avg ⇒ Object
Returns the value of attribute reply_rate_avg.
6 7 8 |
# File 'lib/hansel/httperf_result_parser.rb', line 6 def reply_rate_avg @reply_rate_avg end |
#reply_rate_max ⇒ Object
Returns the value of attribute reply_rate_max.
6 7 8 |
# File 'lib/hansel/httperf_result_parser.rb', line 6 def reply_rate_max @reply_rate_max end |
#reply_rate_min ⇒ Object
Returns the value of attribute reply_rate_min.
6 7 8 |
# File 'lib/hansel/httperf_result_parser.rb', line 6 def reply_rate_min @reply_rate_min end |
#reply_rate_stddev ⇒ Object
Returns the value of attribute reply_rate_stddev.
6 7 8 |
# File 'lib/hansel/httperf_result_parser.rb', line 6 def reply_rate_stddev @reply_rate_stddev end |
#reply_time ⇒ Object
Returns the value of attribute reply_time.
6 7 8 |
# File 'lib/hansel/httperf_result_parser.rb', line 6 def reply_time @reply_time end |
#request_rate ⇒ Object
Returns the value of attribute request_rate.
6 7 8 |
# File 'lib/hansel/httperf_result_parser.rb', line 6 def request_rate @request_rate end |
#status ⇒ Object
Returns the value of attribute status.
6 7 8 |
# File 'lib/hansel/httperf_result_parser.rb', line 6 def status @status end |
Instance Method Details
#parse(httperf_result) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/hansel/httperf_result_parser.rb', line 59 def parse httperf_result @httperf_result = httperf_result @input.each_line do |line| parse_line line end self end |
#parse_connection_rate(line) ⇒ Object
18 19 20 |
# File 'lib/hansel/httperf_result_parser.rb', line 18 def parse_connection_rate line @httperf_result.connection_rate = $1.to_f if line =~ /^Connection rate: (\d+\.\d)/ end |
#parse_errors(line) ⇒ Object
34 35 36 |
# File 'lib/hansel/httperf_result_parser.rb', line 34 def parse_errors line @httperf_result.errors = $1.to_i if line =~ /^Errors: total (\d+)/ end |
#parse_line(line) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/hansel/httperf_result_parser.rb', line 51 def parse_line line %w(parse_replies parse_connection_rate parse_request_rate parse_reply_time parse_net_io parse_errors parse_status parse_reply_rate).map(&:to_sym).each do |method| self.send method, line end end |
#parse_net_io(line) ⇒ Object
30 31 32 |
# File 'lib/hansel/httperf_result_parser.rb', line 30 def parse_net_io line @httperf_result.net_io = $1.to_f if line =~ /^Net I\/O: (\d+\.\d)/ end |
#parse_replies(line) ⇒ Object
14 15 16 |
# File 'lib/hansel/httperf_result_parser.rb', line 14 def parse_replies line @httperf_result.replies = $1.to_i if line =~ /^Total: .*replies (\d+)/ end |
#parse_reply_rate(line) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/hansel/httperf_result_parser.rb', line 42 def parse_reply_rate line if line =~ /^Reply rate .*min (\d+\.\d) avg (\d+\.\d) max (\d+\.\d) stddev (\d+\.\d)/ @httperf_result.reply_rate_min = $1.to_f @httperf_result.reply_rate_avg = $2.to_f @httperf_result.reply_rate_max = $3.to_f @httperf_result.reply_rate_stddev = $4.to_f end end |
#parse_reply_time(line) ⇒ Object
26 27 28 |
# File 'lib/hansel/httperf_result_parser.rb', line 26 def parse_reply_time line @httperf_result.reply_time = $1.to_f if line =~ /^Reply time .* response (\d+\.\d)/ end |
#parse_request_rate(line) ⇒ Object
22 23 24 |
# File 'lib/hansel/httperf_result_parser.rb', line 22 def parse_request_rate line @httperf_result.request_rate = $1.to_f if line =~ /^Request rate: (\d+\.\d)/ end |
#parse_status(line) ⇒ Object
38 39 40 |
# File 'lib/hansel/httperf_result_parser.rb', line 38 def parse_status line @httperf_result.status = $1.to_i if line =~ /^Reply status: 1xx=\d+ 2xx=\d+ 3xx=\d+ 4xx=\d+ 5xx=(\d+)/ end |