YUKI Hiroshi
null+****@clear*****
Thu Oct 24 18:31:02 JST 2013
YUKI Hiroshi 2013-10-24 18:31:02 +0900 (Thu, 24 Oct 2013) New Revision: a1374b2257e4815369a7f9996d03bff774d88f4e https://github.com/droonga/fluent-plugin-droonga/commit/a1374b2257e4815369a7f9996d03bff774d88f4e Message: Benchmark: Define methods to subscribe to automatically generated terms Modified files: benchmark/benchmark.rb Modified: benchmark/benchmark.rb (+37 -0) =================================================================== --- benchmark/benchmark.rb 2013-10-24 18:01:32 +0900 (963d579) +++ benchmark/benchmark.rb 2013-10-24 18:31:02 +0900 (e19d272) @@ -15,6 +15,8 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +require "droonga/client" + class Benchmark class Terms class << self @@ -36,4 +38,39 @@ class Benchmark (("a".."z").to_a + ("A".."Z").to_a + (0..9).to_a).shuffle[0..7].join end end + + TERMS_STEP = 1000 + + def initialize(params) + @params = params + @terms = Terms.generate + @client = Droonga::Client.new(tag: @params[:tag], port: @params[:port]) + @watching_terms = [] + end + + def run + TERMS_STEP.times do + add_subscriber + end + end + + def add_subscriber + term =****@terms***** + subscribe_envelope = envelope_to_subscribe(term) + @client.connection.send_receive(subscribe_envelope) + @watching_terms << term + end + + def envelope_to_subscribe(term) + { + "id" => Time.now.to_f.to_s, + "date" => Time.now, + "statusCode" => 200, + "type" => "watch.subscribe", + "body" => { + "condition" => term, + "subscriber" => term, + }, + } + end end -------------- next part -------------- HTML����������������������������...Download