class GroongaQueryLog::Command::CheckPerformanceRegression::QueryStatistic

Attributes

query[R]

Public Class Methods

new(query, old, new, threshold) click to toggle source
# File lib/groonga-query-log/command/check-performance-regression.rb, line 290
def initialize(query, old, new, threshold)
  super(old, new, threshold)
  @query = query
end

Public Instance Methods

operation_sets() click to toggle source
# File lib/groonga-query-log/command/check-performance-regression.rb, line 299
def operation_sets
  old_operation_name_sets = @old.group_by do |statistic|
    statistic.operations.collect do |operation|
      operation[:name]
    end
  end
  new_operation_name_sets = @new.group_by do |statistic|
    statistic.operations.collect do |operation|
      operation[:name]
    end
  end

  operation_sets = []
  operation_name_sets =
    (old_operation_name_sets.keys & new_operation_name_sets.keys)
  operation_name_sets.each do |operation_names|
    old = old_operation_name_sets[operation_names]
    next if old.nil?
    new = new_operation_name_sets[operation_names]
    next if new.nil?
    statistics = operation_names.size.times.collect do |i|
      old_operations = old.collect do |statistic|
        statistic.operations[i]
      end
      new_operations = new.collect do |statistic|
        statistic.operations[i]
      end
      operation = old_operations[0]
      OperationStatistic.new(operation,
                             i,
                             old_operations,
                             new_operations,
                             @threshold)
    end
    operation_set = OperationSet.new(operation_names, statistics)
    operation_sets << operation_set
  end
  operation_sets
end
slow?() click to toggle source
# File lib/groonga-query-log/command/check-performance-regression.rb, line 295
def slow?
  @threshold.slow_query?(diff_elapsed_time, ratio)
end

Private Instance Methods

compute_mean(statistics) click to toggle source
# File lib/groonga-query-log/command/check-performance-regression.rb, line 340
def compute_mean(statistics)
  elapsed_times = statistics.collect do |statistic|
    statistic.elapsed / 1000.0 / 1000.0 / 1000.0
  end
  elapsed_times.inject(:+) / elapsed_times.size
end