Class: Viiite::Command::Plot
- Inherits:
-
Object
- Object
- Viiite::Command::Plot
- Includes:
- Commons
- Defined in:
- lib/viiite/command/plot.rb,
lib/viiite/command/plot/to_text.rb,
lib/viiite/command/plot/to_gnuplot.rb,
lib/viiite/command/plot/to_highcharts.rb
Overview
Report benchmarking results as a plot
SYNOPSIS
viiite #{command_name} [BENCHFILE]
OPTIONS #summarized_options
Defined Under Namespace
Modules: GnuplotUtils
Instance Method Summary collapse
- #execute(argv) ⇒ Object
- #load_style(file, reference = nil) ⇒ Object
- #to_gnuplot(lispy, op) ⇒ Object
- #to_gnuplot_query(lispy, op) ⇒ Object
- #to_highcharts(lispy, op) ⇒ Object
- #to_highcharts_query(lispy, op) ⇒ Object
- #to_text(lispy, op) ⇒ Object
- #to_text_query(lispy, op) ⇒ Object
Methods included from Commons
Instance Method Details
#execute(argv) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/viiite/command/plot.rb', line 70 def execute(argv) lispy = Alf.lispy op = single_source(argv) do |bdb, arg| bdb.dataset(arg) end op = send(:"to_#{@render}_query", lispy, op) if @debug Alf::Renderer.text(op).execute($stdout) else send(:"to_#{@render}", lispy, op) end end |
#load_style(file, reference = nil) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/viiite/command/plot.rb', line 58 def load_style(file, reference = nil) if reference file = File.join("..", file) file = File.(file, reference) end if File.extname(file) == ".rb" Kernel.eval(File.read(file)) else Alf::Reader.reader(file).to_rel end end |
#to_gnuplot(lispy, op) ⇒ Object
29 30 31 32 |
# File 'lib/viiite/command/plot/to_gnuplot.rb', line 29 def to_gnuplot(lispy, op) puts "set terminal #{@gnuplot_term}" GnuplotUtils.to_plots(op.to_a, $stdout) end |
#to_gnuplot_query(lispy, op) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/viiite/command/plot/to_gnuplot.rb', line 15 def to_gnuplot_query(lispy, op) lispy = Alf.lispy op = lispy.summarize(op, [@graph, @series, @abscissa].compact, {:y => "avg{ #{@ordinate} }"}) op = lispy.join(op, @serie_style) if @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, @graph_style) if @graph_style op = lispy.rename(op, :graph => :title) op end |
#to_highcharts(lispy, op) ⇒ Object
31 32 33 34 |
# File 'lib/viiite/command/plot/to_highcharts.rb', line 31 def to_highcharts(lispy, op) require 'json' puts op.to_a.to_json end |
#to_highcharts_query(lispy, op) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/viiite/command/plot/to_highcharts.rb', line 14 def to_highcharts_query(lispy, op) lispy = Alf.lispy op = lispy.summarize(op, [@graph, @series, @abscissa].compact, {:y => "avg{ #{@ordinate} }"}) op = lispy.rename(op, @graph => :graph, @abscissa => :x, @series => :serie) op = lispy.summarize(op, [:x, :y], {:data => lispy.collect{ [x, y] }}, {:allbut => true}) op = lispy.rename(op, :serie => :name) op = lispy.group(op, [:name, :data], :series) op = lispy.join(op, @graph_style) if @graph_style op = lispy.extend(op, :title => lambda{ title.merge(:text => graph) }) op = lispy.project(op, [:graph], {:allbut => true}) op end |
#to_text(lispy, op) ⇒ Object
24 25 26 |
# File 'lib/viiite/command/plot/to_text.rb', line 24 def to_text(lispy, op) Alf::Renderer.text(op).execute($stdout) end |
#to_text_query(lispy, op) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/viiite/command/plot/to_text.rb', line 12 def to_text_query(lispy, op) lispy = Alf.lispy op = lispy.summarize(op, [@graph, @series, @abscissa].compact, {:y => "avg{ #{@ordinate} }"}) 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.rename(op, :graph => :title) op end |