lib/benchmark/http/statistics.rb in benchmark-http-0.8.1 vs lib/benchmark/http/statistics.rb in benchmark-http-0.8.2

- old
+ new

@@ -46,15 +46,15 @@ def sequential_duration duration / @concurrency end def count - @samples.count + @samples.size end def per_second(duration = self.sequential_duration) - @samples.count.to_f / duration.to_f + @samples.size.to_f / duration.to_f end def latency duration.to_f / count.to_f end @@ -65,24 +65,24 @@ return ratio < difference end def average if @samples.any? - @samples.sum / @samples.count + @samples.sum / @samples.size end end def valid? - @samples.count > 1 + @samples.size > 1 end # Computes Population Variance, σ^2. def variance if valid? average = self.average - return @samples.map{|n| (n - average)**2}.sum / @samples.count + return @samples.map{|n| (n - average)**2}.sum / @samples.size end end # Population Standard Deviation, σ def standard_deviation @@ -91,11 +91,11 @@ end end def standard_error if standard_deviation = self.standard_deviation - standard_deviation / Math.sqrt(@samples.count) + standard_deviation / Math.sqrt(@samples.size) end end def add(duration, result = nil) @samples << duration @@ -133,20 +133,20 @@ end until confident?(confidence_factor) end def print(out = STDOUT) if self.valid? - out.puts "#{@samples.count} samples. #{per_second} requests per second. S/D: #{Seconds[standard_deviation]}." + out.puts "#{@samples.size} samples. #{per_second} requests per second. S/D: #{Seconds[standard_deviation]}." else out.puts "Not enough samples." end end private def confident?(factor) - if @samples.count > @concurrency + if @samples.size > @concurrency return self.standard_error < (self.average * factor) end return false end @@ -168,10 +168,10 @@ 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]}." + 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 end