Sha256: 142522200e8386eb0df06e3b133bb093682c314645bd68e1d1ea8cb781436a7f

Contents?: true

Size: 1023 Bytes

Versions: 15

Compression:

Stored size: 1023 Bytes

Contents

require 'worker_roulette'

def pub(iterations)
  instance = WorkerRoulette::WorkerRoulette.start(evented: false)
  work_order = {'ding dong' => "hello_foreman_" * 100}
  iterations.times do |iteration|
    sender = 'sender_' + (30_000 * rand).to_i.to_s
    foreman = instance.foreman(sender, 'good_channel')
    foreman.enqueue_work_order(work_order)
    puts "published: #{iteration}" if iteration % 10_000 == 0
  end
end

def sub(iterations)
  instance = WorkerRoulette::WorkerRoulette.start(evented: true)
  @tradesman = instance.tradesman('good_channel')
  @received = 0
  @tradesman.wait_for_work_orders do |work|
    @received += work.length
    puts @received if @received % (iterations / 10) == 0
  end
end

def start(action, iterations = 1_000_000)
  EM.kqueue = true
  socket_max = 50_000
  EventMachine.set_descriptor_table_size(socket_max)

  EM.run do
    Signal.trap("INT") {
      EM.stop_event_loop
    }
    Signal.trap("TERM") {
      EM.stop_event_loop
    }

    self.send(action, iterations)
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
nexia_worker_roulette-0.2.9 spec/benchmark/irb_demo_runner.rb
nexia_worker_roulette-0.2.8 spec/benchmark/irb_demo_runner.rb
nexia_worker_roulette-0.2.7 spec/benchmark/irb_demo_runner.rb
nexia_worker_roulette-0.2.6 spec/benchmark/irb_demo_runner.rb
nexia_worker_roulette-0.2.5 spec/benchmark/irb_demo_runner.rb
nexia_worker_roulette-0.2.4 spec/benchmark/irb_demo_runner.rb
nexia_worker_roulette-0.2.3 spec/benchmark/irb_demo_runner.rb
nexia_worker_roulette-0.2.2 spec/benchmark/irb_demo_runner.rb
nexia_worker_roulette-0.2.1 spec/benchmark/irb_demo_runner.rb
nexia_worker_roulette-0.2.0 spec/benchmark/irb_demo_runner.rb
worker_roulette-0.1.13 spec/benchmark/irb_demo_runner.rb
worker_roulette-0.1.12 spec/benchmark/irb_demo_runner.rb
nexia_worker_roulette-0.1.12 spec/benchmark/irb_demo_runner.rb
nexia_worker_roulette-0.1.11 spec/benchmark/irb_demo_runner.rb
worker_roulette-0.1.9 spec/benchmark/irb_demo_runner.rb