Skip to content

Commit 179312c

Browse files
committed
Extract method to load benchmark data from JSON file
1 parent 0d5931c commit 179312c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

lib/graph_renderer.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ class GraphRenderer
2424
DEFAULT_LEGEND_MARGIN = 4.0
2525

2626
def self.render(json_path, png_path, title_font_size: 16.0, legend_font_size: 12.0, marker_font_size: 10.0)
27-
json = JSON.load_file(json_path)
28-
ruby_descriptions = json.fetch("metadata")
29-
data = json.fetch("raw_data")
30-
baseline = ruby_descriptions.first.first
31-
bench_names = data.first.last.keys
27+
ruby_descriptions, data, baseline, bench_names = load_benchmark_data(json_path)
3228

3329
# ruby_descriptions, bench_names, table
3430
graph = Gruff::Bar.new(DEFAULT_WIDTH)
@@ -53,4 +49,14 @@ def self.render(json_path, png_path, title_font_size: 16.0, legend_font_size: 12
5349
graph.write(png_path)
5450
png_path
5551
end
52+
53+
def self.load_benchmark_data(json_path)
54+
json = JSON.load_file(json_path)
55+
ruby_descriptions = json.fetch("metadata")
56+
data = json.fetch("raw_data")
57+
baseline = ruby_descriptions.first.first
58+
bench_names = data.first.last.keys
59+
60+
[ruby_descriptions, data, baseline, bench_names]
61+
end
5662
end

0 commit comments

Comments
 (0)