blob: 47de7cba1665e490122da63134e56c7219120318 [file] [log] [blame]
Kevin Clark2ddd9d72008-06-18 01:18:47 +00001$:.unshift File.dirname(__FILE__) + '/../lib'
2require 'thrift'
3require 'thrift/server/nonblockingserver'
4$:.unshift File.dirname(__FILE__) + "/gen-rb"
5require 'BenchmarkService'
6HOST = 'localhost'
7PORT = 42587
8
9class BenchmarkHandler
10 # 1-based index into the fibonacci sequence
11 def fibonacci(n)
12 seq = [1, 1]
13 3.upto(n) do
14 seq << seq[-1] + seq[-2]
15 end
16 seq[n-1] # n is 1-based
17 end
18end
19
20handler = BenchmarkHandler.new
21processor = ThriftBenchmark::BenchmarkService::Processor.new(handler)
22transport = Thrift::ServerSocket.new(HOST, PORT)
23transportFactory = Thrift::FramedTransportFactory.new
Kevin Clarkbfb198d2008-06-18 01:18:52 +000024logger = Logger.new(STDERR)
Kevin Clarkb6791312008-06-18 01:19:23 +000025logger.level = Logger::WARN
Kevin Clarkbfb198d2008-06-18 01:18:52 +000026Thrift::NonblockingServer.new(processor, transport, transportFactory, nil, 20, logger).serve