Class: BenchmarkDriver::Output::Gruff
- Inherits:
-
BulkOutput
- Object
- BulkOutput
- BenchmarkDriver::Output::Gruff
- Defined in:
- lib/benchmark_driver/output/gruff.rb
Constant Summary collapse
- GRAPH_PATH =
'graph.png'
Instance Method Summary collapse
- #bulk_output(job_context_result:, metrics:) ⇒ Object
-
#initialize(contexts:) ⇒ Gruff
constructor
A new instance of Gruff.
- #with_context(context, &block) ⇒ Object
- #with_job(job, &block) ⇒ Object
Constructor Details
#initialize(contexts:) ⇒ Gruff
10 11 12 13 |
# File 'lib/benchmark_driver/output/gruff.rb', line 10 def initialize(contexts:, **) super @contexts = contexts end |
Instance Method Details
#bulk_output(job_context_result:, metrics:) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/benchmark_driver/output/gruff.rb', line 17 def bulk_output(job_context_result:, metrics:) print "rendering graph..." g = Gruff::SideBar.new g.theme = { colors: ['#3285e1', '#e2c13e', '#489d32', '#12a702', '#aedaa9', '#6886B4', '#D1695E', '#8A6EAF', '#EFAA43'], marker_color: '#dddddd', font_color: 'black', background_colors: 'white' } metric = metrics.first # only one metric is supported for now g.x_axis_label = metric.unit g.legend_font_size = 10.0 g.marker_font_size = 14.0 g.minimum_value = 0 results = job_context_result.values.map(&:values).flatten g.maximum_value = (results.map(&:values).map(&:values).flatten.max * 1.2).to_i if job_context_result.keys.size == 1 # Use Ruby version for base axis job = job_context_result.keys.first g.labels = Hash[job_context_result[job].keys.map.with_index { |context, index| [index, context.name] }] g.data job.name, job_context_result[job].values.map { |result| result.values.fetch(metric) } else # Use benchmark name for base axis, use different colors for different Ruby versions jobs = job_context_result.keys g.labels = Hash[jobs.map.with_index { |job, index| [index, job.name] }] @contexts.each do |context| g.data context.name, jobs.map { |job| job_context_result[job][context].values.fetch(metric) } end end g. = 0.6 g.write(GRAPH_PATH) puts ": #{GRAPH_PATH}" end |
#with_context(context, &block) ⇒ Object
58 59 60 61 |
# File 'lib/benchmark_driver/output/gruff.rb', line 58 def with_context(context, &block) puts " * #{context.name}..." super end |
#with_job(job, &block) ⇒ Object
53 54 55 56 |
# File 'lib/benchmark_driver/output/gruff.rb', line 53 def with_job(job, &block) puts "* #{job.name}..." super end |