blob: e8d335157b431415b434cdf6a19dd2436b1007ad [file] [log] [blame]
Kevin Clarkd3cee022008-06-18 01:19:09 +00001$:.unshift File.dirname(__FILE__) + '/../lib'
2require 'thrift'
3require 'thrift/server/nonblockingserver'
4$:.unshift File.dirname(__FILE__) + "/gen-rb"
5require 'BenchmarkService'
6
7class Client
8 def initialize(host, port, clients_per_process, calls_per_client)
9 @host = host
10 @port = port
11 @clients_per_process = clients_per_process
12 @calls_per_client = calls_per_client
13 end
14
15 def run
16 @clients_per_process.times do
17 socket = Thrift::Socket.new(@host, @port)
18 transport = Thrift::FramedTransport.new(socket)
19 protocol = Thrift::BinaryProtocol.new(transport)
20 client = ThriftBenchmark::BenchmarkService::Client.new(protocol)
21 begin
22 transport.open
23 rescue
24 Marshal.dump [:connection_failure, Time.now], STDOUT
25 else
26 Marshal.dump [:start, Time.now], STDOUT
27 @calls_per_client.times do
28 Marshal.dump [:call_start, Time.now], STDOUT
29 client.fibonacci(15)
30 Marshal.dump [:call_end, Time.now], STDOUT
31 end
32 transport.close
33 Marshal.dump [:end, Time.now], STDOUT
34 end
35 end
36 end
37end
38
39host, port, clients_per_process, calls_per_client = ARGV
40
41Client.new(host, port.to_i, clients_per_process.to_i, calls_per_client.to_i).run