Kevin Clark | 2ddd9d7 | 2008-06-18 01:18:47 +0000 | [diff] [blame] | 1 | $:.unshift File.dirname(__FILE__) + '/../lib' |
| 2 | require 'thrift' |
| 3 | require 'thrift/server/nonblockingserver' |
| 4 | $:.unshift File.dirname(__FILE__) + "/gen-rb" |
| 5 | require 'BenchmarkService' |
| 6 | HOST = 'localhost' |
| 7 | PORT = 42587 |
| 8 | |
| 9 | class 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 |
| 18 | end |
| 19 | |
| 20 | handler = BenchmarkHandler.new |
| 21 | processor = ThriftBenchmark::BenchmarkService::Processor.new(handler) |
| 22 | transport = Thrift::ServerSocket.new(HOST, PORT) |
| 23 | transportFactory = Thrift::FramedTransportFactory.new |
Kevin Clark | bfb198d | 2008-06-18 01:18:52 +0000 | [diff] [blame] | 24 | logger = Logger.new(STDERR) |
Kevin Clark | b679131 | 2008-06-18 01:19:23 +0000 | [diff] [blame] | 25 | logger.level = Logger::WARN |
Kevin Clark | bfb198d | 2008-06-18 01:18:52 +0000 | [diff] [blame] | 26 | Thrift::NonblockingServer.new(processor, transport, transportFactory, nil, 20, logger).serve |