YUKI Hiroshi
null+****@clear*****
Fri Nov 28 16:29:51 JST 2014
YUKI Hiroshi 2014-11-28 16:29:51 +0900 (Fri, 28 Nov 2014) New Revision: 18ba33defb280c24269191b00bad9bd7f945b28f https://github.com/droonga/drnbench/commit/18ba33defb280c24269191b00bad9bd7f945b28f Message: Reuse clients Modified files: lib/drnbench/client/http.rb Modified: lib/drnbench/client/http.rb (+13 -4) =================================================================== --- lib/drnbench/client/http.rb 2014-11-28 16:25:22 +0900 (9587a44) +++ lib/drnbench/client/http.rb 2014-11-28 16:29:51 +0900 (fb3d7aa) @@ -37,6 +37,7 @@ module Drnbench def run @thread = Thread.new do + clients = {} start_time = Time.now loop do if****@runne*****? @@ -48,10 +49,14 @@ module Drnbench request =****@runne*****_request request = fixup_request(request) - client = Droonga::Client.new(:protocol => :http, - :host => request["host"], - :port => request["port"], - :timeout => request["timeout"]) + client_params = { + :protocol => :http, + :host => request["host"], + :port => request["port"], + :timeout => request["timeout"], + } + client = clients[client_params.to_s] ||= Droonga::Client.new(client_params) + request["headers"] ||= {} request["headers"]["user-agent"] = "Ruby/#{RUBY_VERSION} Droonga::Benchmark::Runner::HttpClient" start_time = Time.now @@ -80,6 +85,10 @@ module Drnbench self end + def client_key(request) + "http:#{request["host"]}:#{request["port"]}/#{request["timeout"]}" + end + def stop return unless @thread -------------- next part -------------- HTML����������������������������... Download