Class: TestProf::TPSProf::Reporter::Text

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/test_prof/tps_prof/reporter/text.rb

Constant Summary

Constants included from Logging

Logging::COLORS

Instance Method Summary collapse

Methods included from Logging

#log

Instance Method Details



14
15
16
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
# File 'lib/test_prof/tps_prof/reporter/text.rb', line 14

def print(profiler)
  groups = profiler.groups

  total_tps = (profiler.total_count / profiler.total_time).round(2)

  msgs = []

  msgs <<
    <<~MSG
      Total TPS (tests per second): #{total_tps}

      Top #{profiler.top_count} slowest suites by TPS (tests per second) (min examples per group: #{profiler.threshold}):

    MSG

  groups.each do |group|
    description = group[:id].top_level_description
    location = group[:id].[:location]
    time = group[:run_time]
    group_time = group[:group_time]
    count = group[:count]
    tps = -group[:tps]

    msgs <<
      <<~GROUP
        #{description.truncate} (#{location}) – #{tps} TPS (#{time.duration} / #{count}), group time: #{group_time.duration}
      GROUP
  end

  log :info, msgs.join
end