Sha256: 87defad819d3f50a8b35016d57fac50805ff3832e3bfa6e75dcf012eb56dec21

Contents?: true

Size: 1.95 KB

Versions: 43

Compression:

Stored size: 1.95 KB

Contents

module Bench
  class Statistics
    include Logging
    
    def initialize(concurrency,iterations,total_time,sessions)
      @sessions = sessions
      @rows = {} # row key is result.marker;
      @total_count = 0
      @total_time = total_time
      @concurrency,@iterations = concurrency,iterations
    end
    
    def process
      @sessions.each do |session|
        session.results.each do |marker,results|
          results.each do |result|
            @rows[result.marker] ||= {}
            row = @rows[result.marker]
            row[:min] ||= 0.0
            row[:max] ||= 0.0
            row[:count] ||= 0
            row[:total_time] ||= 0.0
            row[:errors] ||= 0
            row[:verification_errors] ||= 0
            row[:min] = result.time if result.time < row[:min] || row[:min] == 0
            row[:max] = result.time if result.time > row[:max]
            row[:count] += 1.0
            row[:total_time] += result.time            
            row[:errors] += 1 if result.error
            row[:verification_errors] += result.verification_error
            @total_count += 1
          end
        end
      end
      self
    end
    
    def average(row)
      row[:total_time] / row[:count]
    end
    
    def print_stats
      logger.info "Statistics:"
      @rows.each do |marker,row|
        logger.info "Request %-15s: min: %0.4f, max: %0.4f, avg: %0.4f, err: %d, verification err: %d" % [marker, row[:min], row[:max], average(row), row[:errors], row[:verification_errors]]
      end
      logger.info "State of MD        : #{Bench.verify_error == 0 ? true : false}"
      logger.info "Concurrency        : #{@concurrency}"
      logger.info "Iterations         : #{@iterations}"
      logger.info "Total Count        : #{@total_count}"
      logger.info "Total Time         : #{@total_time}"
      logger.info "Throughput(req/s)  : #{@total_count / @total_time}"
      logger.info "Throughput(req/min): #{(@total_count / @total_time) * 60.0}"
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
rhosync-2.1.18.beta2 bench/lib/bench/statistics.rb
rhosync-2.1.18.beta1 bench/lib/bench/statistics.rb
rhosync-2.1.17 bench/lib/bench/statistics.rb
rhosync-2.1.17.beta7 bench/lib/bench/statistics.rb
rhosync-2.1.17.beta6 bench/lib/bench/statistics.rb
rhosync-2.1.17.beta5 bench/lib/bench/statistics.rb
rhosync-2.1.17.beta4 bench/lib/bench/statistics.rb
rhosync-2.1.17.beta3 bench/lib/bench/statistics.rb
rhosync-2.1.17.beta2 bench/lib/bench/statistics.rb
rhosync-2.1.17.beta1 bench/lib/bench/statistics.rb
rhosync-2.1.16 bench/lib/bench/statistics.rb
rhosync-2.1.15 bench/lib/bench/statistics.rb
rhosync-2.1.14 bench/lib/bench/statistics.rb
rhosync-2.1.13 bench/lib/bench/statistics.rb
rhosync-2.1.12 bench/lib/bench/statistics.rb
rhosync-2.1.11 bench/lib/bench/statistics.rb
rhosync-2.1.10 bench/lib/bench/statistics.rb
rhosync-2.1.7 bench/lib/bench/statistics.rb
rhosync-2.1.6 bench/lib/bench/statistics.rb
rhosync-2.1.3 bench/lib/bench/statistics.rb