Class: TestProf::RubyProf::Report

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/test_prof/ruby_prof.rb

Overview

Wrapper over RubyProf profiler and printer

Constant Summary

Constants included from Logging

Logging::COLORS

Instance Method Summary collapse

Methods included from Logging

#build_log_msg, #colorize, #log

Constructor Details

#initialize(profiler) ⇒ Report

Returns a new instance of Report.



84
85
86
# File 'lib/test_prof/ruby_prof.rb', line 84

def initialize(profiler)
  @profiler = profiler
end

Instance Method Details

#dump(name) ⇒ Object

Stop profiling and generate the report using provided name.



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/test_prof/ruby_prof.rb', line 90

def dump(name)
  result = @profiler.stop

  if config.eliminate_methods?
    result.eliminate_methods!(config.eliminate_methods)
  end

  printer_type, printer_class = config.resolve_printer
  path = build_path name, printer_type

  File.open(path, 'w') do |f|
    printer_class.new(result).print(f, min_percent: config.min_percent)
  end

  log :info, "RubyProf report generated: #{path}"
end