[Groonga-commit] groonga/groonga-query-log [master] sized-grouped-operations: indent

Back to archive index

Haruka Yoshihara null+****@clear*****
Wed Dec 12 16:28:00 JST 2012


Haruka Yoshihara	2012-12-12 16:28:00 +0900 (Wed, 12 Dec 2012)

  New Revision: c068cda3f63c25e69da9a6a5ec3cda33ff8c9204
  https://github.com/groonga/groonga-query-log/commit/c068cda3f63c25e69da9a6a5ec3cda33ff8c9204

  Log:
    sized-grouped-operations: indent

  Modified files:
    lib/groonga/query-log/analyzer/sized-grouped-operations.rb

  Modified: lib/groonga/query-log/analyzer/sized-grouped-operations.rb (+47 -47)
===================================================================
--- lib/groonga/query-log/analyzer/sized-grouped-operations.rb    2012-12-12 16:27:19 +0900 (1c18178)
+++ lib/groonga/query-log/analyzer/sized-grouped-operations.rb    2012-12-12 16:28:00 +0900 (cec3160)
@@ -20,65 +20,65 @@
 module Groonga
   module QueryLog
     class Analyzer
-    class SizedGroupedOperations < Array
-      def initialize
-        @max_size = 10
-        @sorter = create_sorter
-      end
-
-      def apply_options(options)
-        @max_size = options[:n_entries]
-      end
+      class SizedGroupedOperations < Array
+        def initialize
+          @max_size = 10
+          @sorter = create_sorter
+        end
 
-      def each
-        i = 0
-        super do |grouped_operation|
-          break if i >= @max_size
-          i += 1
-          yield(grouped_operation)
+        def apply_options(options)
+          @max_size = options[:n_entries]
         end
-      end
 
-      def <<(operation)
-        each do |grouped_operation|
-          if grouped_operation[:name] == operation[:name] and
-              grouped_operation[:context] == operation[:context]
-            elapsed = operation[:relative_elapsed_in_seconds]
-            grouped_operation[:total_elapsed] += elapsed
-            grouped_operation[:n_operations] += 1
-            replace(sort_by(&@sorter))
-            return self
+        def each
+          i = 0
+          super do |grouped_operation|
+            break if i >= @max_size
+            i += 1
+            yield(grouped_operation)
           end
         end
 
-        grouped_operation = {
-          :name => operation[:name],
-          :context => operation[:context],
-          :n_operations => 1,
-          :total_elapsed => operation[:relative_elapsed_in_seconds],
-        }
-        buffer_size = @max_size * 100
-        if size < buffer_size
-          super(grouped_operation)
-          replace(sort_by(&@sorter))
-        else
-          if****@sorte*****(grouped_operation) < @sorter.call(last)
+        def <<(operation)
+          each do |grouped_operation|
+            if grouped_operation[:name] == operation[:name] and
+                grouped_operation[:context] == operation[:context]
+              elapsed = operation[:relative_elapsed_in_seconds]
+              grouped_operation[:total_elapsed] += elapsed
+              grouped_operation[:n_operations] += 1
+              replace(sort_by(&@sorter))
+              return self
+            end
+          end
+
+          grouped_operation = {
+            :name => operation[:name],
+            :context => operation[:context],
+            :n_operations => 1,
+            :total_elapsed => operation[:relative_elapsed_in_seconds],
+          }
+          buffer_size = @max_size * 100
+          if size < buffer_size
             super(grouped_operation)
-            sorted_operations = sort_by(&@sorter)
-            sorted_operations.pop
-            replace(sorted_operations)
+            replace(sort_by(&@sorter))
+          else
+            if****@sorte*****(grouped_operation) < @sorter.call(last)
+              super(grouped_operation)
+              sorted_operations = sort_by(&@sorter)
+              sorted_operations.pop
+              replace(sorted_operations)
+            end
           end
+          self
         end
-        self
-      end
 
-      private
-      def create_sorter
-        lambda do |grouped_operation|
-          -grouped_operation[:total_elapsed]
+        private
+        def create_sorter
+          lambda do |grouped_operation|
+            -grouped_operation[:total_elapsed]
+          end
         end
       end
     end
-    end
   end
 end
-------------- next part --------------
HTML����������������������������...
Download 



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