Skip to content

Commit 8013bba

Browse files
committed
Extract method to configure the graph
1 parent 179312c commit 8013bba

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

lib/graph_renderer.rb

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,8 @@ class GraphRenderer
2626
def self.render(json_path, png_path, title_font_size: 16.0, legend_font_size: 12.0, marker_font_size: 10.0)
2727
ruby_descriptions, data, baseline, bench_names = load_benchmark_data(json_path)
2828

29-
# ruby_descriptions, bench_names, table
3029
graph = Gruff::Bar.new(DEFAULT_WIDTH)
31-
graph.title = "Speedup ratio relative to #{ruby_descriptions.keys.first}"
32-
graph.title_font_size = title_font_size
33-
graph.theme = THEME
34-
graph.labels = bench_names.map.with_index { |bench, index| [index, bench] }.to_h
35-
graph.show_labels_for_bar_values = true
36-
graph.bottom_margin = DEFAULT_BOTTOM_MARGIN
37-
graph.legend_margin = DEFAULT_LEGEND_MARGIN
38-
graph.legend_font_size = legend_font_size
39-
graph.marker_font_size = marker_font_size
30+
configure_graph(graph, ruby_descriptions, bench_names, title_font_size, legend_font_size, marker_font_size)
4031

4132
ruby_descriptions.each do |ruby, description|
4233
speedups = bench_names.map { |bench|
@@ -59,4 +50,16 @@ def self.load_benchmark_data(json_path)
5950

6051
[ruby_descriptions, data, baseline, bench_names]
6152
end
53+
54+
def self.configure_graph(graph, ruby_descriptions, bench_names, title_font_size, legend_font_size, marker_font_size)
55+
graph.title = "Speedup ratio relative to #{ruby_descriptions.keys.first}"
56+
graph.title_font_size = title_font_size
57+
graph.theme = THEME
58+
graph.labels = bench_names.map.with_index { |bench, index| [index, bench] }.to_h
59+
graph.show_labels_for_bar_values = true
60+
graph.bottom_margin = DEFAULT_BOTTOM_MARGIN
61+
graph.legend_margin = DEFAULT_LEGEND_MARGIN
62+
graph.legend_font_size = legend_font_size
63+
graph.marker_font_size = marker_font_size
64+
end
6265
end

0 commit comments

Comments
 (0)