class Middleman::Profiling::RubyProfProfiler

A profiler that uses ruby-prof

Public Class Methods

new() click to toggle source
# File lib/middleman-core/profiling.rb, line 33
def initialize
  begin
    require 'ruby-prof'
  rescue LoadError
    raise "To use the --profile option, you must 'gem install ruby-prof' (and include it in your Gemfile if running under bundle exec)"
  end
end

Public Instance Methods

report(report_name) click to toggle source
# File lib/middleman-core/profiling.rb, line 45
def report(report_name)
  result = RubyProf.stop

  printer = RubyProf::GraphHtmlPrinter.new(result)
  outfile = File.join("profile", report_name)
  outfile = (outfile + '.html') unless outfile.end_with? '.html'
  FileUtils.mkdir_p(File.dirname(outfile))
  File.open(outfile, 'w') do |f|
    printer.print(f, :min_percent=> 1)
  end
end
start() click to toggle source
# File lib/middleman-core/profiling.rb, line 41
def start
  RubyProf.start
end