Sha256: 6b86ea6423fbce78072aa3aca1957bbb403fb2214cf1bfc42334061d31ca485c

Contents?: true

Size: 1.93 KB

Versions: 9

Compression:

Stored size: 1.93 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
      bench_log "Statistics:"
      @rows.each do |marker,row|
        bench_log "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
      bench_log "State of MD        : #{Bench.verify_error == 0 ? true : false}"
      bench_log "Concurrency        : #{@concurrency}"
      bench_log "Iterations         : #{@iterations}"
      bench_log "Total Count        : #{@total_count}"
      bench_log "Total Time         : #{@total_time}"
      bench_log "Throughput(req/s)  : #{@total_count / @total_time}"
      bench_log "Throughput(req/min): #{(@total_count / @total_time) * 60.0}"
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rhoconnect-3.0.5 bench/lib/bench/statistics.rb
rhoconnect-3.0.4 bench/lib/bench/statistics.rb
rhoconnect-3.0.3 bench/lib/bench/statistics.rb
rhoconnect-3.0.2 bench/lib/bench/statistics.rb
rhoconnect-3.0.1 bench/lib/bench/statistics.rb
rhoconnect-3.0.0 bench/lib/bench/statistics.rb
rhoconnect-3.0.0.rc1 bench/lib/bench/statistics.rb
rhoconnect-3.0.0.beta3 bench/lib/bench/statistics.rb
rhoconnect-3.0.0.beta1 bench/lib/bench/statistics.rb