Created
August 3, 2016 07:18
-
-
Save prathmeshranaut/5b5d33c1f6357ffe0753df6ae2ae3904 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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