Class: Bench::Command::Plot

Inherits:
Object
  • Object
show all
Defined in:
lib/bench/command/plot.rb

Overview

Report benchmarking results as a plot

SYNOPSIS

bench #{command_name} [BENCHFILE]

OPTIONS #summarized_options

Instance Method Summary (collapse)

Instance Method Details

- (Object) execute(args)

Raises:

  • (Quickl::InvalidArgument)


74
75
76
77
78
79
80
81
82
83
84
# File 'lib/bench/command/plot.rb', line 74

def execute(args)
  raise Quickl::InvalidArgument if args.size > 1
  op = query Alf::Reader.reader(args.first || $stdin)
  case @render
  when :text
    Alf::Renderer.text(op).execute($stdout)
  when :gnuplot
    $stdout << "set terminal #{@term}\n"
    Bench::Formatter::Plot::to_plots(op.to_a, $stdout)
  end
end

- (Object) query(op)



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/bench/command/plot.rb', line 60

def query(op)
  lispy = Alf.lispy
  op = lispy.summarize(op, [@graph, @series, @abscissa].compact, 
                           {:y => "avg{ #{@ordinate} }"})
  op = lispy.join(op, Alf::Reader.reader(@serie_style))
  op = lispy.rename(op, @graph  => :graph, @abscissa => :x, @series => :serie)
  op = lispy.group(op, [:x, :y], :data)
  op = lispy.rename(op, :serie => :title)
  op = lispy.group(op, [:graph], :series, {:allbut => true})
  op = lispy.join(op, Alf::Reader.reader(@graph_style))
  op = lispy.rename(op, :graph => :title)
  op
end