Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save prathmeshranaut/1dda7800458c1eafe4df0c5012b6b567 to your computer and use it in GitHub Desktop.
Save prathmeshranaut/1dda7800458c1eafe4df0c5012b6b567 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
require 'celluloid/autostart'
require 'benchmark'
message = :ohai
BM_COUNT = 1_000_000
Benchmark.bmbm do |bm|
mailbox = Celluloid.mailbox
selective_mailbox = Celluloid.mailbox
class Foo; end
foo = Foo.new
bm.report('mailbox send message') do
BM_COUNT.times do
mailbox << message
end
end
# BM_COUNT.times do
# selective_mailbox << foo
# end
bm.report('mailbox receive message') do
BM_COUNT.times do
mailbox.receive
end
end
# bm.report('mailbox selectivity receiving message') do
# BM_COUNT.times do
# selective_mailbox.receive { |msg| msg.is_a? Foo }
# end
# end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment