Website/slides/cse501/2018/data/CT-InPractice/Rakefile
2018-10-09 08:32:20 -04:00

95 lines
2 KiB
Ruby

require 'rubygems'
require 'gnuplot'
$:.push(".")
require 'util'
require 'plot'
require 'csvx'
$modes = [:deterministic,:classic,:partition,:inline,:hybrid]
$query_names = {
:q1_noagg => "Q1",
:q3_noagg => "Q3",
:q5_noagg => "Q5",
:q9_noagg => "Q9"
}
# plot_output :pdf, size: "5in,2.5in", fsize: "12"
plot_output :aqua
# auto_open_plots :true
# $plot_auto_open = true
def to_seconds(time)
case time
when /([0-9]+)m([0-9.]+)s/ then
$1.to_i * 60 + $2.to_f
when /\?/ then
0
when /Timeout/ then
1000000
else
raise "Unknown time value '#{time}'"
end
end
def sort_by_cols(order,hash)
order.map { |col|
hash[col]
}
end
$data =
File.csv("data.csv", separator: / *, */).
map { |db,q,sf,mode,time|
[ (db+"_"+sf).to_sym,
[q.to_sym,
[mode.to_sym, to_seconds(time)]]]
}.reduce { |db, db_trials|
db_trials.reduce { |q, q_trials|
sort_by_cols($modes, q_trials.to_h)
}
}
def plot_timing_bar_plot(gp, db, details = {})
clusters = $query_names.keys.sort;
data = sort_by_cols(
clusters,
$data[db]
).map {|timings|
det_t = timings.shift
timings.map { |t| t / det_t * 100}
}
gp.yrange details.fetch(:yrange, "[0:300]")
gp.key "font \"Times-Roman,10\" opaque box top left"
gp.ylabel "% of Deterministic Time"
draw_clustered_bar_plot(gp,
data: data,
dataset_labels:
$modes.map {|m| m.to_s.capitalize}[1..-1],
group_labels:
clusters.map {|c| $query_names[c]},
box_style:
lambda {|i| "boxes fill solid #{(i.to_f/6)+0.25} lc #{$pretty_styles[4-i][:lt]}"}
)
end
plot 'sqlite100m' => "Rakefile" do |gp|
plot_timing_bar_plot(gp, :sqlite_100m)
end
plot 'sqlite1g' => "Rakefile" do |gp|
plot_timing_bar_plot(gp, :sqlite_1g)
end
plot 'dbx100m' => "Rakefile" do |gp|
plot_timing_bar_plot(gp, :oracle_100m,
yrange: "[0:400]"
)
end
plot 'dbx1g' => "Rakefile" do |gp|
plot_timing_bar_plot(gp, :oracle_1g,
yrange: "[0:1400]"
)
end
task :all => ['sqlite100m', 'sqlite1g', 'dbx100m', 'dbx1g']
task :default => :all