Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 35 lines (29 sloc) 0.748 kB
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
require 'celluloid'
require 'benchmark/ips'
class ExampleActor
include Celluloid
def example_method; end
end
example_actor = ExampleActor.new
mailbox = Celluloid::Mailbox.new
latch_in, latch_out = Queue.new, Queue.new
latch = Thread.new do
while true
n = latch_in.pop
for i in 0..n; mailbox.receive; end
latch_out << :done
end
end
Benchmark.ips do |ips|
ips.report("spawn") { ExampleActor.new.terminate }
ips.report("calls") { example_actor.example_method }
ips.report("async calls") { example_actor.example_method! }
ips.report("messages") do |n|
latch_in << n
for i in 0..n; mailbox << :message; end
latch_out.pop
end
end
Jump to Line
Something went wrong with that request. Please try again.