Class: Benny::Reporters::Stdout

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

Instance Method Summary collapse

Constructor Details

#initializeStdout

Returns a new instance of Stdout.



8
9
10
# File 'lib/benny/reporters/stdout.rb', line 8

def initialize
  @io = $stdout
end

Instance Method Details

#report(metrics) ⇒ Object

rubocop:disable Metrics/AbcSize, Metrics/MethodLength



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/benny/reporters/stdout.rb', line 12

def report(metrics)  # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
  result = {}
  labels = ['']

  metrics.each.with_index do |metric, _i|
    labels << metric[:env_name]
    metric[:benchmarks].each do |bm|
      result[bm[:name]] ||= []
      result[bm[:name]] << bm[:total].round(5)
    end
  end

  rows = result.map do |k, v|
    ([k] + v)
  end

  puts Terminal::Table.new(headings: labels, rows: rows)
end