Class: HanselCore::HttperfResultParser

Inherits:
Object
  • Object
show all
Defined in:
lib/hansel/httperf_result_parser.rb

Overview

Parse httperf output.

Instance Attribute Summary collapse

Instance Method Summary collapse

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_rateObject

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

#errorsObject

Returns the value of attribute errors.



6
7
8
# File 'lib/hansel/httperf_result_parser.rb', line 6

def errors
  @errors
end

#net_ioObject

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

#rateObject

Returns the value of attribute rate.



6
7
8
# File 'lib/hansel/httperf_result_parser.rb', line 6

def rate
  @rate
end

#repliesObject

Returns the value of attribute replies.



6
7
8
# File 'lib/hansel/httperf_result_parser.rb', line 6

def replies
  @replies
end

#reply_rate_avgObject

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_maxObject

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_minObject

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_stddevObject

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_timeObject

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_rateObject

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

#statusObject

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