Class: Benchmark::HTTP::Statistics

Inherits:
Stopwatch
  • Object
show all
Defined in:
lib/benchmark/http/statistics.rb

Instance Attribute Summary

Attributes inherited from Stopwatch

#concurrency, #samples, #total_time

Instance Method Summary collapse

Methods inherited from Stopwatch

#average, #count, #duration, #latency, #measure, #per_second, #sample, #sequential_duration, #similar?, #standard_deviation, #standard_error, #valid?, #variance

Constructor Details

#initializeStatistics

Returns a new instance of Statistics.



167
168
169
170
171
172
# File 'lib/benchmark/http/statistics.rb', line 167

def initialize(*)
	super
	
	# The count of the status codes seen in the responses:
	@responses = Hash.new{|h,k| 0}
end

Instance Method Details

#add(duration, result) ⇒ Object



174
175
176
177
178
# File 'lib/benchmark/http/statistics.rb', line 174

def add(duration, result)
	super
	
	@responses[result.status] += 1
end


180
181
182
183
184
185
186
187
188
# File 'lib/benchmark/http/statistics.rb', line 180

def print(out = STDOUT)
	if valid?
		counts = @responses.sort.collect{|status, count| "#{count}x #{status}"}.join("; ")
		
		out.puts "#{@samples.count} samples: #{counts}. #{per_second.round(2)} requests per second. S/D: #{Seconds[standard_deviation]}."
	else
		out.puts "Not enough samples."
	end
end