Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save prathmeshranaut/5b5d33c1f6357ffe0753df6ae2ae3904 to your computer and use it in GitHub Desktop.
Save prathmeshranaut/5b5d33c1f6357ffe0753df6ae2ae3904 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