1
|
|
|
# frozen_string_literal: true |
2
|
|
|
|
3
|
1 |
|
module NoSE |
4
|
1 |
|
module CLI |
5
|
|
|
# Add a command to generate a graphic of the schema from a workload |
6
|
1 |
|
class NoSECLI < Thor |
7
|
1 |
|
desc 'collect-results CSV_FILES', |
8
|
|
|
'collect results from CSV_FILES and produce a `gnuplot` data file' |
9
|
|
|
|
10
|
1 |
|
long_desc <<-LONGDESC |
11
|
|
|
`nose collect-results` combines results from multiple statement |
12
|
|
|
execution runs and produces a data file which can be used to generate |
13
|
|
|
clustered bar charts in `gnuplot`. |
14
|
|
|
LONGDESC |
15
|
|
|
|
16
|
1 |
|
option :total, type: :boolean, default: false, aliases: '-t', |
17
|
|
|
desc: 'whether to include a line for totals in the '\ |
18
|
|
|
'graph' |
19
|
|
|
|
20
|
1 |
|
def collect_results(*csv_files) |
21
|
|
|
# Load the data and output the header |
22
|
|
|
data = load_data csv_files, options[:total] |
23
|
|
|
labels = data.map { |datum| datum.first['label'] } |
24
|
|
|
puts((['Group'] + labels).join("\t")) |
25
|
|
|
|
26
|
|
|
# Output the mean for each schema |
27
|
|
|
group_data(data).each { |group| collect_group_data group, data } |
28
|
|
|
end |
29
|
|
|
|
30
|
1 |
|
private |
31
|
|
|
|
32
|
|
|
# Combine the results into groups |
33
|
|
|
# @return [Array] |
34
|
1 |
|
def group_data(data) |
35
|
|
|
# Make sure we collect all rows, keeping the total last |
36
|
|
|
groups = data.map { |d| d.map { |r| r['group'] } }.flatten.uniq |
37
|
|
|
groups.delete 'TOTAL' |
38
|
|
|
groups << 'TOTAL' if options[:total] |
39
|
|
|
|
40
|
|
|
groups |
41
|
|
|
end |
42
|
|
|
|
43
|
|
|
# Collect the results for a single group |
44
|
|
|
# @return [void] |
45
|
1 |
|
def collect_group_data(group, data) |
46
|
|
|
print group + "\t" |
47
|
|
|
data.each do |datum| |
48
|
|
|
row = datum.find { |r| r['group'] == group } |
49
|
|
|
print((row.nil? ? '' : row['mean'].to_s) + "\t") |
50
|
|
|
end |
51
|
|
|
puts |
52
|
|
|
end |
53
|
|
|
end |
54
|
|
|
end |
55
|
|
|
end |
56
|
|
|
|