class Object

Constants

DEFAULT_RUBY_PROF_OPTIONS
KCACHEGRIND_RUBY_PROF_OPTIONS

Public Instance Methods

ruby_prof(options = DEFAULT_RUBY_PROF_OPTIONS) { || ... } click to toggle source
# File lib/ruby_prof_helper.rb, line 11
def ruby_prof(options = DEFAULT_RUBY_PROF_OPTIONS)
  RubyProf.start
  options = DEFAULT_RUBY_PROF_OPTIONS.merge options
  yield
ensure
  callgraph = RubyProf.stop

  callgraph.eliminate_methods!([
    /IRB::Irb#signal_status/,
    /Fixnum#>/,
    /Arel::/,
    /Array#each/,
    /Array#map/,
    /Enumerable#reduce/,
    /Enumerable#map/,
    /Enumerable#collect/,
    /Array#collect/,
    /Array#select/
  ])

  printer  = options.fetch(:printer)
  filename = options.fetch(:filename)

  printer.new(callgraph).print(File.new(filename, 'w'))
end