# require 'profile' require 'druby2' client = DRuby::Client.new('localhost', '4242', false) obj = client.resolve("foo") N = 10000 puts "Normal functions, no synchronization" start_time = Time.now (1..N).each do |i| obj.foo(i) end obj.sync() total_time = Time.now - start_time puts " Total time: #{total_time}" puts " Messages per second: #{N/total_time}" # TODO: For some reason, mixing normal function calls with oneway calls # causes the oneways to run at 1/10 regular speed client = DRuby::Client.new('localhost', '4242', false) obj = client.resolve("foo") puts "Oneway functions, no synchronization" start_time = Time.now (1..N).each do |i| obj.oneway(:foo, i) end obj.sync() total_time = Time.now - start_time puts " Total time: #{total_time}" puts " Messages per second: #{N/total_time}" puts "You should see the number #{N}:" puts obj.bar() puts "You should see an object Foo with an element @i=#{N}" puts obj.inspect() foo = obj.methods() if foo.index("dup") then puts "uh oh, shouldn't have found dup" end if obj.respond_to?("clone") then puts "uh oh, obj should not respond to clone" end except = false begin obj.clone() rescue NameError except = true end if !except then puts "uh oh, I was able to clone obj" end if !obj.respond_to?("foo") then puts "uh oh, obj should respond to foo!" end puts "You should see the numbers 1, 2, and 3 on separate lines:" obj.each do |i| puts i end puts "You should now see a RuntimeError get thrown:" obj.throw_exception()