Sha256: ee120967886fb0f6691ffd98e3dd8a681b15dea39da7421970b94965961dc138
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
#!/usr/bin/env ruby require 'benchmark' require 'rubygems' require 'bundler' Bundler.setup require 'dcell' DCell.setup DCell.run! RECEIVER_PORT = 2043 $receiver_pid = Process.spawn Gem.ruby, File.expand_path("../receiver.rb", __FILE__) STDERR.print "Waiting for test node to start up..." socket = nil 30.times do begin socket = TCPSocket.open("127.0.0.1", RECEIVER_PORT) break if socket rescue Errno::ECONNREFUSED STDERR.print "." sleep 1 end end if socket STDERR.puts " done!" socket.close else STDERR.puts " FAILED!" raise "couldn't connect to test node!" end class AsyncPerformanceTest include Celluloid def initialize(progenator, n = 10000) @n = n @receiver = progenator.spawn_async_receiver(n, current_actor) end def run @n.times { @receiver.increment! } wait :complete end def complete signal :complete end end DCell.start :id => "messaging_node", :addr => "tcp://127.0.0.1:2042", :directory => { :id => "benchmark_receiver", :addr => "tcp://127.0.0.1:#{RECEIVER_PORT}" } receiver = DCell::Node['benchmark_receiver'] progenator = receiver[:progenator] test = AsyncPerformanceTest.new progenator time = Benchmark.measure { test.run }.real messages_per_second = 1 / time * 10000 puts "messages_per_second: #{"%0.2f" % messages_per_second}" Process.kill 9, $receiver_pid Process.wait $receiver_pid rescue nil exit 0
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dcell-0.13.0.pre | benchmarks/messaging.rb |
dcell-0.12.0.pre | benchmarks/messaging.rb |