Class: Benny::Reporters::Gruff

Inherits:
Object
  • Object
show all
Defined in:
lib/benny/reporters/gruff.rb

Instance Method Summary collapse

Instance Method Details

#report(metrics) ⇒ Object

rubocop:disable Metrics/AbcSize, Metrics/MethodLength



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/benny/reporters/gruff.rb', line 8

def report(metrics) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
  g = ::Gruff::SideBar.new(800)
  g.title = 'Benchmark results'
  result = {}
  labels = {}

  metrics.each.with_index do |metric, i|
    labels[i] = metric[:env_name]
    metric[:benchmarks].each do |bm|
      result[bm[:name]] ||= []
      result[bm[:name]] << bm[:total]
    end
  end

  g.labels = labels
  result.each { |k, v| g.data(k, v) }

  g.write('result.png')
end