Module: RSpecTelemetry::SummaryPrinter
- Defined in:
- lib/rspec_telemetry/summary.rb
Class Method Summary collapse
- .example_section(summary, _config) ⇒ Object
- .factory_section(summary, _config) ⇒ Object
- .print(summary, config, io = config.summary_io) ⇒ Object
Class Method Details
.example_section(summary, _config) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/rspec_telemetry/summary.rb', line 116 def example_section(summary, _config) slow = summary.slow_examples return [] if slow.empty? lines = ["Slow examples:", ""] slow.each_with_index do |e, i| lines << "#{i + 1}. #{e.example_id}" lines << " duration: #{Formatting.fixed(e.duration_ms)}ms" lines << " factory_bot_total: #{Formatting.fixed(e.factory_bot_total_ms)}ms (#{e.factory_bot_count} calls)" lines << "" end lines end |
.factory_section(summary, _config) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/rspec_telemetry/summary.rb', line 98 def factory_section(summary, _config) tops = summary.top_factories return [] if tops.empty? lines = ["FactoryBot telemetry summary", "", "Top factories by self time (子factoryを除く):", ""] tops.each_with_index do |f, i| lines << "#{i + 1}. #{f.key}" lines << " count: #{f.count}" lines << " self_total: #{Formatting.fixed(f.self_total_ms)}ms" lines << " total: #{Formatting.fixed(f.total_ms)}ms" lines << " avg: #{Formatting.fixed(f.avg_ms)}ms" lines << " max: #{Formatting.fixed(f.max_ms)}ms" lines << "" end lines end |
.print(summary, config, io = config.summary_io) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/rspec_telemetry/summary.rb', line 84 def print(summary, config, io = config.summary_io) return unless config.print_summary lines = [] lines.concat(factory_section(summary, config)) lines.concat(example_section(summary, config)) return if lines.empty? io.puts io.puts(lines.join("\n")) rescue => e warn("[rspec-telemetry] failed to print summary: #{e.class}: #{e.}") end |