examples/echo_client.rb in pigato-0.2.27 vs examples/echo_client.rb in pigato-0.3.0
- old
+ new
@@ -1,23 +1,29 @@
#!/usr/bin/env ruby
-require 'pry-remote'
require "rubygems"
require "#{File.dirname(__FILE__)}/../lib/pigato.rb"
#require "pigato"
require 'thread'
-client = Pigato::Client.new('tcp://localhost:55555')
-client.start
+ts = []
-Process.daemon
+[0,1,2,3,4,5,6].each do |tid|
+ ts << Thread.new {
+ client = Pigato::Client.new('tcp://127.0.0.1:55555')
+ client.start
-client.start
-requests = 1000
-d1 = Time.now
-requests.times do |i|
- begin
- client.request('echo', 'Hello world1')
- end
+ requests = 10000
+ d1 = Time.now
+ requests.times do |i|
+ begin
+ client.request('echo', 'Hello world1')
+ end
+ end
+ d2 = Time.now
+ puts "#{requests} requests/replies processed (#{(d2 - d1) * 1000} milliseconds)"
+ }
end
-d2 = Time.now
-puts "#{requests} requests/replies processed (#{(d2 - d1) * 1000} milliseconds)"
+
+ts.each do |to|
+ to.join
+end