Class: GroongaQueryLog::Command::CheckPerformanceRegression

Inherits:
GroongaQueryLog::CommandLine show all
Defined in:
lib/groonga-query-log/command/check-performance-regression.rb

Defined Under Namespace

Classes: Checker, OperationSet, OperationStatistic, QueryStatistic, Statistic, Threshold

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ CheckPerformanceRegression

Returns a new instance of CheckPerformanceRegression.



32
33
34
# File 'lib/groonga-query-log/command/check-performance-regression.rb', line 32

def initialize(options={})
  setup_options(options)
end

Instance Method Details

#run(arguments) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/groonga-query-log/command/check-performance-regression.rb', line 36

def run(arguments)
  paths = []
  begin
    paths = @option_parser.parse!(arguments)
  rescue OptionParser::InvalidOption => error
    $stderr.puts(error)
    return false
  end

  if paths.size != 2
    $stderr.puts("old query log and new query log must be specified.")
    return false
  end

  old_query_paths = resolve_path(paths[0])
  return false if old_query_paths.nil?
  new_query_paths = resolve_path(paths[1])
  return false if new_query_paths.nil?

  old_statistics = analyze(old_query_paths)
  return false if old_statistics.nil?
  new_statistics = analyze(new_query_paths)
  return false if new_statistics.nil?

  open_output do |output|
    checker = Checker.new(old_statistics,
                          new_statistics,
                          output,
                          @threshold,
                          @target_queries)
    checker.check
  end
end