YUKI Hiroshi
null+****@clear*****
Wed Nov 6 17:48:15 JST 2013
YUKI Hiroshi 2013-11-06 17:48:15 +0900 (Wed, 06 Nov 2013) New Revision: cf41e963b44ab0486a06728314afe36f1dbc695f https://github.com/droonga/fluent-plugin-droonga/commit/cf41e963b44ab0486a06728314afe36f1dbc695f Message: Benchmark: receive all messages correctly Modified files: benchmark/utils.rb benchmark/watch/benchmark-notify.rb Modified: benchmark/utils.rb (+10 -8) =================================================================== --- benchmark/utils.rb 2013-11-06 15:21:24 +0900 (52b4476) +++ benchmark/utils.rb 2013-11-06 17:48:15 +0900 (c6e6712) @@ -16,6 +16,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA require "json" +require "thread" require "droonga/watch_schema" module DroongaBenchmark @@ -208,6 +209,7 @@ module DroongaBenchmark } options = default_options.merge(options) @socket = TCPServer.new(options[:host], options[:port]) + start end def close @@ -222,19 +224,19 @@ module DroongaBenchmark @socket.addr[1] end - def receive(options={}) - if IO.select([@socket], nil, nil, options[:timeout]) + def new_message + @messages.pop + end + + def start + @messages = Queue.new + Thread.new do client =****@socke***** - message = nil unpacker = MessagePack::Unpacker.new(client) unpacker.each do |object| - message = object - break + @messages.push(object) end client.close - message - else - nil end end end Modified: benchmark/watch/benchmark-notify.rb (+6 -5) =================================================================== --- benchmark/watch/benchmark-notify.rb 2013-11-06 15:21:24 +0900 (134b389) +++ benchmark/watch/benchmark-notify.rb 2013-11-06 17:48:15 +0900 (39781b2) @@ -50,13 +50,14 @@ class NotifyBenchmark end def run - notifications = [] @n_times.times do |index| do_feed("#{WATCHING_KEYWORD} #{index}") end - received = [] - received << @receiver.receive(:timeout => @timeout) - notifications += received if received.is_a?(Array) + + notifications = [] + while notifications.size != @n_times do + notifications << @receiver.new_message + end notifications end @@ -115,7 +116,7 @@ options[:n_steps].times do |try_count| notify_benchmark.add_subscribers(notify_benchmark.n_subscribers) if try_count > 0 label = "#{notify_benchmark.n_subscribers} subscribers" percentage = nil - result = Benchmark.bmbm do |benchmark| + result = Benchmark.bm do |benchmark| benchmark.report(label) do sent_notifications = notify_benchmark.run percentage = sent_notifications.size.to_f / options[:n_times] * 100 -------------- next part -------------- HTML����������������������������... Descargar