lib/benchmark/http/statistics.rb in benchmark-http-0.6.0 vs lib/benchmark/http/statistics.rb in benchmark-http-0.7.0

- old
+ new

@@ -24,25 +24,20 @@ module HTTP class Stopwatch def initialize(concurrency = 0) @samples = [] - @total_time = 0 - # The number of currently executing measurements: @count = 0 @concurrency = concurrency @start_time = nil end # The individual samples' durations. attr :samples - # The sequential time of all samples. - attr :total_time - # The maximum number of executing measurements at any one time. attr :concurrency def duration @samples.sum @@ -54,12 +49,12 @@ def count @samples.count end - def per_second - @samples.count.to_f / total_time.to_f + def per_second(duration = self.sequential_duration) + @samples.count.to_f / duration.to_f end def latency duration.to_f / count.to_f end @@ -126,18 +121,12 @@ self.add(end_time - start_time, result) return result ensure @count -= 1 - - if @count == 0 and end_time - @total_time += end_time - @start_time - @start_time = nil - end end def sample(confidence_factor, &block) - # warmup yield begin measure(&block) end until confident?(confidence_factor)