benchmarks/actor.rb in celluloid-io-0.13.0.pre vs benchmarks/actor.rb in celluloid-io-0.13.0.pre2
- old
+ new
@@ -1,17 +1,17 @@
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
-require 'celluloid'
+require 'celluloid/io'
require 'benchmark/ips'
class ExampleActor
include Celluloid::IO
def initialize
- @condition = Condition.new
+ @condition = Celluloid::Condition.new
end
def example_method; end
def finished
@@ -22,17 +22,17 @@
@condition.wait
end
end
example_actor = ExampleActor.new
-mailbox = Celluloid::Mailbox.new
+mailbox = Celluloid::IO::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
+ for i in 0...n; mailbox.receive; end
latch_out << :done
end
end
Benchmark.ips do |ips|
@@ -47,11 +47,14 @@
example_actor.async.finished
waiter.value
end
+# Deadlocking o_O
+=begin
ips.report("messages") do |n|
latch_in << n
- for i in 0..n; mailbox << :message; end
+ for i in 0...n; mailbox << :message; end
latch_out.pop
end
+=end
end