lib/stella/adapter/httperf.rb in stella-0.5.4 vs lib/stella/adapter/httperf.rb in stella-0.5.5
- old
+ new
@@ -27,15 +27,16 @@
attr_accessor :server_name, :session_cookies, :ssl, :ssl_ciphers, :ssl_no_reuse, :verbose
attr_writer :version, :add_header, :wlog, :wsess, :wsesslog, :wset
def initialize(options={}, arguments=[])
- super(options, arguments)
- @name = 'httperf'
+ @name = 'httperf'
@private_variables = ['private_variables', 'name', 'arguments', 'load_factor', 'working_directory']
@load_factor = 1
+
+ super(options, arguments)
end
def error
@@ -73,17 +74,14 @@
# After calling run
def after
- save_stats
end
- #httperf --hog --server=queen --uri=/0k.html --num-conns=10000 --rate=0 --timeout=30 --think-timeout=0
- def process_options(arguments)
+ def process_arguments(arguments)
- options = OpenStruct.new
opts = OptionParser.new
opts.on('--hog') do @hog = true end
opts.on('--server=S', String) do |v| @server = v end
opts.on('--server-name=S', String) do |v| @server_name = v end
opts.on('--port=N', Integer) do |v| @port = v end
@@ -124,21 +122,25 @@
opts.on('--recv-buffer=N', Integer) do |v| @recv_buffer = v end
opts.on('--send-buffer=N', Integer) do |v| @send_buffer = v end
opts.on('--wlog=S', String) do |v| @wlog = Stella::Util::expand_str(v) end
- opts.on('--wsess=S', String) do |v| @wsess = Stella::Util::expand_str(v) end
+ opts.on('--wsess=S', String) do |v| @wsess = Stella::Util::expand_str(v, Integer) end
opts.on('--wsesslog=S', String) do |v| @wsesslog = Stella::Util::expand_str(v) end
opts.on('--wset=S', String) do |v| @wset = Stella::Util::expand_str(v) end
+
+ if @wsess
+ end
+
# parse! removes the options it finds.
# It also fails when it finds unknown switches (i.e. -X)
# Which should leave only the remaining arguments (URIs in this case)
opts.parse!(arguments)
-
- options
+ self.arguments = arguments
+
rescue OptionParser::InvalidOption => ex
# We want to replace this text so we grab just the name of the argument
badarg = ex.message.gsub('invalid option: ', '')
raise InvalidArgument.new(badarg)
end
@@ -179,17 +181,21 @@
list.each do |agent|
add_header("User-Agent", agent)
end
end
def vusers
- @rate
+ @wsess[1]
end
+ def vuser_rate
+ "#{vusers}/#{rate}"
+ end
+
def vusers=(v)
0
end
def requests
- @num_conns # TODO: also check wsess and wlog params
+ @num_conns || (@wsess[0] * @wsess[1])
end
def requests=(v)
0
end
def vuser_requests
@@ -222,11 +228,11 @@
#end
# Siege writes the summary to STDERR
- def stats_file
+ def summary_file
File.new(stdout_path) if File.exists?(stdout_path)
end
def rc_file
File.join(@working_directory, "siegerc")
@@ -263,14 +269,14 @@
# Net I/O: 2.8 KB/s (0.0*10^6 bps)
#
# Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
# Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0
- def stats
- return unless stats_file
+ def summary
+ return unless summary_file
- raw = stats_file.readlines.join
+ raw = summary_file.readlines.join
stats = Stella::Test::Run::Summary.new
raw.scan(/Request rate: (\d+?\.\d+?) req.s .(\d+?\.\d+?) ms.req./) do |rate,time|
stats.transaction_rate = rate.to_f
stats.response_time = (time.to_f) / 1000
@@ -281,14 +287,14 @@
stats.successful = rep.to_i
stats.failed = conn.to_i - rep.to_i # maybe this should be from the Error line
stats.transactions = conn.to_i
end
- raw.scan(/Reply size [B]: header (\d+\.\d+?) content (\d+\.\d+?) footer (\d+\.\d+?) .total (\d+\.\d+?)./) do |h,c,f,t|
- stats.data_transferred = ((t.to_f || 0 ) / 1_048_576).to_f # TODO: convert from bytes to MB
+ raw.scan(/header (\d+\.\d+?)\s+.+?\s+.total (\d+\.\d+?)./) do |h,t|
+ stats.data_transferred = ((t.to_f || 0 ) / 1_048_576).to_f
+ stats.headers_transferred = ((h.to_f || 0 ) / 1_048_576).to_f
end
stats.vusers = self.vusers
-
stats
end
\ No newline at end of file