1212
1313# Renders benchmark data as a graph
1414class GraphRenderer
15+ DEFAULT_WIDTH = 1600
16+ COLOR_PALETTE = %w[ #3285e1 #489d32 #e2c13e #8A6EAF #D1695E ] . freeze
17+ THEME = {
18+ colors : COLOR_PALETTE ,
19+ marker_color : '#dddddd' ,
20+ font_color : 'black' ,
21+ background_colors : 'white'
22+ } . freeze
23+ DEFAULT_BOTTOM_MARGIN = 30.0
24+ DEFAULT_LEGEND_MARGIN = 4.0
25+
1526 def self . render ( json_path , png_path , title_font_size : 16.0 , legend_font_size : 12.0 , marker_font_size : 10.0 )
1627 json = JSON . load_file ( json_path )
1728 ruby_descriptions = json . fetch ( "metadata" )
@@ -20,19 +31,14 @@ def self.render(json_path, png_path, title_font_size: 16.0, legend_font_size: 12
2031 bench_names = data . first . last . keys
2132
2233 # ruby_descriptions, bench_names, table
23- g = Gruff ::Bar . new ( 1600 )
34+ g = Gruff ::Bar . new ( DEFAULT_WIDTH )
2435 g . title = "Speedup ratio relative to #{ ruby_descriptions . keys . first } "
2536 g . title_font_size = title_font_size
26- g . theme = {
27- colors : %w[ #3285e1 #489d32 #e2c13e #8A6EAF #D1695E ] ,
28- marker_color : '#dddddd' ,
29- font_color : 'black' ,
30- background_colors : 'white'
31- }
37+ g . theme = THEME
3238 g . labels = bench_names . map . with_index { |bench , index | [ index , bench ] } . to_h
3339 g . show_labels_for_bar_values = true
34- g . bottom_margin = 30.0
35- g . legend_margin = 4.0
40+ g . bottom_margin = DEFAULT_BOTTOM_MARGIN
41+ g . legend_margin = DEFAULT_LEGEND_MARGIN
3642 g . legend_font_size = legend_font_size
3743 g . marker_font_size = marker_font_size
3844
0 commit comments