Sha256: cb9c2f8e544dc41b4692829c7e8affb97eff269adb9693ec74c0e7a6afb2c85d

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

#!/usr/bin/env ruby

require 'benchmark'
require 'bundler/setup'
require 'rabbit_feed'

# Prevent deprecation warnings
I18n.enforce_available_locales = true

RabbitFeed.environment = 'development'

payload = 'abc' * 5000
number_of_events = 5000

EventDefinitions do
  define_event('test_event', version: '1.0.0') do
    defined_as do
      'An event used in the benchmarking tests'
    end
    payload_contains do
      field('data', type: 'string', definition: 'A large chunk of text')
    end
  end
end

puts "Publishing #{number_of_events} events..."
Benchmark.bm do |x|
  x.report { number_of_events.times { RabbitFeed::Producer.publish_event 'test_event', 'data' => payload } }
end

events_consumed = 0

EventRouting do
  accept_from('non_rails_app') do
    event('test_event') do |_event|
      events_consumed += 1
      Thread.main.raise Interrupt if events_consumed >= number_of_events
    end
  end
  accept_from('rails_app') do
    event('user_creates_beaver') do |event|
    end
    event('user_updates_beaver') do |event|
    end
    event('user_deletes_beaver') do |event|
    end
  end
end

puts "Consuming #{number_of_events} events..."
Benchmark.bm do |x|
  x.report do
    begin
      RabbitFeed::Consumer.run
    rescue Interrupt
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rabbit_feed-3.0.3 example/non_rails_app/bin/benchmark
rabbit_feed-3.0.2 example/non_rails_app/bin/benchmark
rabbit_feed-3.0.1 example/non_rails_app/bin/benchmark
rabbit_feed-3.0.0 example/non_rails_app/bin/benchmark