class Drnbench::Reporters::ThroughputReporter

Public Class Methods

new(label) click to toggle source
# File lib/drnbench/reporters/throughput-reporter.rb, line 24
def initialize(label)
  @label = label
  @data_file = Tempfile.new("drnbench-throughput-data")
end

Public Instance Methods

add_data(time, qps) click to toggle source
# File lib/drnbench/reporters/throughput-reporter.rb, line 29
def add_data(time, qps)
  @data_file.puts([time, qps].join("\t"))
end
report(output_directory) click to toggle source
# File lib/drnbench/reporters/throughput-reporter.rb, line 33
def report(output_directory)
  FileUtils.mkdir_p(output_directory)
  generate_chart(output_directory)
end

Private Instance Methods

generate_chart(output_directory) click to toggle source
# File lib/drnbench/reporters/throughput-reporter.rb, line 39
      def generate_chart(output_directory)
        @data_file.flush
        gnuplot = Chart::Gnuplot.new
        gnuplot.write(<<-INPUT)
set output "#{output_directory}/throughput.pdf"
set title "Throughput"

set xlabel "Time (second)"
set ylabel "Queries per Second (qps)"
plot "#{@data_file.path}" using 1:2 with linespoints linestyle 1 \\
   title "#{@label}"
        INPUT
        gnuplot.run
      end