Sha256: d65ec89eccb8158954b04824430e717d120304b2bc2c2f1df6de600915844a83

Contents?: true

Size: 1.04 KB

Versions: 49

Compression:

Stored size: 1.04 KB

Contents

module Bench
  class Runner
    include Logging
    include Timer
    attr_reader :threads
    
    def initialize
      @threads = []
      @sessions = []
    end
    
    def test(concurrency,iterations,&block)
      thread_id = 0
      total_time = time do
        concurrency.times do
          sleep rand(2)
          thread = Thread.new(block) do |t|
            tid, iteration = thread_id,0
            iterations.times do
              s = Session.new(tid,iteration)
              @sessions << s
              begin
                yield Bench,s
              rescue Exception => e
                puts "error running script: #{e.inspect}"
              end    
              iteration += 1
            end
          end
          thread_id += 1    
          threads << thread
        end
        begin 
          threads.each { |t| t.join }
        rescue RestClient::RequestTimeout => e
          logger.info "Request timed out #{e}"
        end
      end
      Bench.sessions = @sessions
      Bench.total_time = total_time
    end    
  end
end  
  

Version data entries

49 entries across 49 versions & 1 rubygems

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