class GroongaQueryLog::Command::Analyzer::Reporter

Attributes

output[R]
slow_operation_threshold[RW]
slow_response_threshold[RW]

Public Class Methods

new(statistics, options={}) click to toggle source
# File lib/groonga-query-log/command/analyzer/reporter.rb, line 28
def initialize(statistics, options={})
  @statistics = statistics
  @options = options
  self.output = @options[:output] || $stdout
  @report_summary = @options[:report_summary]
  @report_summary = true if @report_summary.nil?
  @report_command_line = @options[:report_command_line]
  @report_command_line = true if @report_command_line.nil?
  @slow_operation_threshold =
    @options[:slow_operation_threshold] ||
    Statistic::DEFAULT_SLOW_OPERATION_THRESHOLD
  @slow_response_threshold =
    @options[:slow_response_threshold] ||
    Statistic::DEFAULT_SLOW_RESPONSE_THRESHOLD
end

Public Instance Methods

each() { |statistic| ... } click to toggle source
# File lib/groonga-query-log/command/analyzer/reporter.rb, line 49
def each
  @statistics.each do |statistic|
    yield statistic
  end
end
output=(output) click to toggle source
# File lib/groonga-query-log/command/analyzer/reporter.rb, line 44
def output=(output)
  @output = output
  @output = $stdout if @output == "-"
end
report() click to toggle source
# File lib/groonga-query-log/command/analyzer/reporter.rb, line 55
def report
  setup do
    report_summary if @report_summary
    report_statistics
  end
end
report_statistics() click to toggle source
# File lib/groonga-query-log/command/analyzer/reporter.rb, line 62
def report_statistics
  each do |statistic|
    report_statistic(statistic)
  end
end

Private Instance Methods

format_time(time) click to toggle source
# File lib/groonga-query-log/command/analyzer/reporter.rb, line 95
def format_time(time)
  if time.nil?
    "NaN"
  else
    time.iso8601(6)
  end
end
setup() { || ... } click to toggle source
# File lib/groonga-query-log/command/analyzer/reporter.rb, line 69
def setup
  setup_output do
    start
    yield
    finish
  end
end
setup_output() { |output| ... } click to toggle source
# File lib/groonga-query-log/command/analyzer/reporter.rb, line 77
def setup_output
  original_output = @output
  if @output.is_a?(String)
    File.open(@output, "w") do |output|
      @output = output
      yield(@output)
    end
  else
    yield(@output)
  end
ensure
  @output = original_output
end
write(*args) click to toggle source
# File lib/groonga-query-log/command/analyzer/reporter.rb, line 91
def write(*args)
  @output.write(*args)
end