[Groonga-commit] droonga/fluent-plugin-droonga at 5f86e98 [master] Indent

Back to archive index

YUKI Hiroshi null+****@clear*****
Fri Oct 25 15:54:07 JST 2013


YUKI Hiroshi	2013-10-25 15:54:07 +0900 (Fri, 25 Oct 2013)

  New Revision: 5f86e98f5c1b37ab52b81671d93a8f474c6ffe48
  https://github.com/droonga/fluent-plugin-droonga/commit/5f86e98f5c1b37ab52b81671d93a8f474c6ffe48

  Message:
    Indent

  Modified files:
    benchmark/benchmark.rb

  Modified: benchmark/benchmark.rb (+77 -77)
===================================================================
--- benchmark/benchmark.rb    2013-10-25 15:53:09 +0900 (e23ed14)
+++ benchmark/benchmark.rb    2013-10-25 15:54:07 +0900 (7e357a1)
@@ -18,102 +18,102 @@
 require "droonga/client"
 
 module Droonga
-class Benchmark
-  class Terms
-    class << self
-      def generate
-        new.to_enum(:each)
+  class Benchmark
+    class Terms
+      class << self
+        def generate
+          new.to_enum(:each)
+        end
       end
-    end
 
-    FIRST_INITIAL_LETTER = "㐀"
-    SUFFIX = "あいうえおかきくけこ"
-    def each
-      initial_letter = FIRST_INITIAL_LETTER
-      while true do
-        yield "#{initial_letter}#{SUFFIX}"
-        initial_letter.succ!
+      FIRST_INITIAL_LETTER = "㐀"
+      SUFFIX = "あいうえおかきくけこ"
+      def each
+        initial_letter = FIRST_INITIAL_LETTER
+        while true do
+          yield "#{initial_letter}#{SUFFIX}"
+          initial_letter.succ!
+        end
       end
     end
-  end
 
-  TERMS_STEP = 1000
+    TERMS_STEP = 1000
 
-  N_TARGETS         = 1000
-  TARGET_PADDING    = "パディング"
-  TARGET_TITLE_SIZE = 100
-  TARGET_BODY_SIZE  = 1000
+    N_TARGETS         = 1000
+    TARGET_PADDING    = "パディング"
+    TARGET_TITLE_SIZE = 100
+    TARGET_BODY_SIZE  = 1000
 
-  def initialize(params)
-    @params = params
-    @terms = Terms.generate
-    @client = Droonga::Client.new(tag: @params[:tag], port: @params[:port])
-  end
+    def initialize(params)
+      @params = params
+      @terms = Terms.generate
+      @client = Droonga::Client.new(tag: @params[:tag], port: @params[:port])
+    end
 
-  def run
-    prepare_watching_subscribers(TERMS_STEP)
-    populate_feeds(0.1)
-    start_at = Time.now
-    @feeds.each do |feed|
-      @client.send(feed)
+    def run
+      prepare_watching_subscribers(TERMS_STEP)
+      populate_feeds(0.1)
+      start_at = Time.now
+      @feeds.each do |feed|
+        @client.send(feed)
+      end
+      end_at = Time.now
     end
-    end_at = Time.now
-  end
 
-  def prepare_watching_subscribers(step)
-    step.times do
-      term =****@terms*****
-      add_subscriber(term)
-      @watching_terms << term
+    def prepare_watching_subscribers(step)
+      step.times do
+        term =****@terms*****
+        add_subscriber(term)
+        @watching_terms << term
+      end
     end
-  end
 
-  def add_subscriber(term)
-    subscribe_envelope = envelope_to_subscribe(term)
-    @client.connection.send_receive(subscribe_envelope)
-  end
+    def add_subscriber(term)
+      subscribe_envelope = envelope_to_subscribe(term)
+      @client.connection.send_receive(subscribe_envelope)
+    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
+    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
 
-  def populate_feeds(incidence)
-    @feeds = []
+    def populate_feeds(incidence)
+      @feeds = []
 
-    n_matched_targets = (N_TARGETS.to_f * incidence).to_i
-    n_unmatched_targets = (N_TARGETS - n_matched_targets)
+      n_matched_targets = (N_TARGETS.to_f * incidence).to_i
+      n_unmatched_targets = (N_TARGETS - n_matched_targets)
 
-    n_matched_targets.times do
-      @feeds << envelope_to_feed(@watching_terms.sample(1))
-    end
+      n_matched_targets.times do
+        @feeds << envelope_to_feed(@watching_terms.sample(1))
+      end
 
-    n_unmatched_targets.times do
-      @feeds << envelope_to_feed(@terms.next)
+      n_unmatched_targets.times do
+        @feeds << envelope_to_feed(@terms.next)
+      end
     end
-  end
 
-  def envelope_to_feed(term)
-    {
-      "id" => Time.now.to_f.to_s,
-      "date" => Time.now,
-      "statusCode" => 200,
-      "type" => "watch.feed",
-      "body" => {
-        "targets" => {
-          "title" => TARGET_PADDING * (TARGET_TITLE_SIZE / TARGET_PADDING.size),
-          "body"  => term + (TARGET_PADDING * (TARGET_BODY_SIZE / TARGET_PADDING.size)),
+    def envelope_to_feed(term)
+      {
+        "id" => Time.now.to_f.to_s,
+        "date" => Time.now,
+        "statusCode" => 200,
+        "type" => "watch.feed",
+        "body" => {
+          "targets" => {
+            "title" => TARGET_PADDING * (TARGET_TITLE_SIZE / TARGET_PADDING.size),
+            "body"  => term + (TARGET_PADDING * (TARGET_BODY_SIZE / TARGET_PADDING.size)),
+          },
         },
-      },
-    }
+      }
+    end
   end
 end
-end
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index