class Benchmark::HTTP::Statistics
Attributes
responses[R]
Public Class Methods
new(*)
click to toggle source
Calls superclass method
Benchmark::HTTP::Stopwatch::new
# File lib/benchmark/http/statistics.rb, line 156 def initialize(*) super # The count of the status codes seen in the responses: @responses = Hash.new{|h,k| 0} end
Public Instance Methods
add(duration, result)
click to toggle source
Calls superclass method
Benchmark::HTTP::Stopwatch#add
# File lib/benchmark/http/statistics.rb, line 169 def add(duration, result) super @responses[result.status] += 1 end
failed()
click to toggle source
# File lib/benchmark/http/statistics.rb, line 165 def failed @responses.sum{|status, count| status >= 400 ? count : 0} end
print(out = STDOUT)
click to toggle source
# File lib/benchmark/http/statistics.rb, line 175 def print(out = STDOUT) if valid? counts = @responses.sort.collect{|status, count| "#{count}x #{status}"}.join("; ") out.puts "#{@samples.size} samples: #{counts}. #{per_second.round(2)} requests per second. S/D: #{Seconds[standard_deviation]}." else out.puts "Not enough samples." end end