Sha256: 7fb2337b2c75552063050dfad8e705fb22aef9819007088e9fc2ffba9d696d49

Contents?: true

Size: 1.32 KB

Versions: 10

Compression:

Stored size: 1.32 KB

Contents

#!/usr/bin/env ruby

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

# Prevent deprecation warnings
I18n.enforce_available_locales = true

RabbitFeed.instance_eval do
  self.log         = Logger.new 'log/rabbit_feed.log'
  self.environment = 'development'
end

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

10 entries across 10 versions & 1 rubygems

Version Path
rabbit_feed-2.3.1 example/non_rails_app/bin/benchmark
rabbit_feed-2.3.0 example/non_rails_app/bin/benchmark
rabbit_feed-2.1.5 example/non_rails_app/bin/benchmark
rabbit_feed-2.1.2 example/non_rails_app/bin/benchmark
rabbit_feed-2.1.1 example/non_rails_app/bin/benchmark
rabbit_feed-2.1.0 example/non_rails_app/bin/benchmark
rabbit_feed-2.0.0 example/non_rails_app/bin/benchmark
rabbit_feed-1.0.2 example/non_rails_app/bin/benchmark
rabbit_feed-1.0.1 example/non_rails_app/bin/benchmark
rabbit_feed-1.0.0 example/non_rails_app/bin/benchmark