forked from celluloid/celluloid-io
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
79 additions
and
5 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
#!/usr/bin/env rake | ||
require 'bundler/gem_tasks' | ||
require 'rspec/core/rake_task' | ||
Dir["tasks/**/*.task"].each { |task| load task } | ||
|
||
RSpec::Core::RakeTask.new | ||
|
||
task :default => :spec | ||
task :default => :spec |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'rubygems' | ||
require 'bundler/setup' | ||
require 'celluloid/io' | ||
require 'benchmark/ips' | ||
|
||
class ExampleActor | ||
include Celluloid::IO | ||
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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'rubygems' | ||
require 'bundler/setup' | ||
require 'celluloid' | ||
require 'benchmark/ips' | ||
require File.expand_path("../../examples/ring", __FILE__) | ||
|
||
# 512-node ring | ||
ring = Ring.new 512 | ||
|
||
Benchmark.ips do |ips| | ||
ips.report("ring-around") { |n| ring.run n } | ||
end |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
|
||
describe Celluloid::IO do | ||
it_behaves_like "a Celluloid Actor", Celluloid::IO | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require 'timeout' | ||
|
||
desc "Run Celluloid benchmarks" | ||
task :benchmark do | ||
# Travis has an out-of-date version of rbx that rashes on the benchmarks | ||
exit 0 if ENV['CI'] and RUBY_ENGINE == 'rbx' | ||
|
||
begin | ||
Timeout.timeout(120) do | ||
glob = File.expand_path("../../benchmarks/*.rb", __FILE__) | ||
Dir[glob].each { |benchmark| load benchmark } | ||
end | ||
rescue Exception, Timeout::Error => ex | ||
puts "ERROR: Couldn't complete benchmark: #{ex.class}: #{ex}" | ||
puts " #{ex.backtrace.join("\n ")}" | ||
|
||
exit 1 unless ENV['CI'] # Hax for running benchmarks on Travis | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'rspec/core/rake_task' | ||
|
||
RSpec::Core::RakeTask.new | ||
|
||
RSpec::Core::RakeTask.new(:rcov) do |task| | ||
task.rcov = true | ||
end |