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 30
def initialize
  require 'ruby-prof'
rescue LoadError
  raise "To use the --profile option, you must add the 'ruby-prof' gem to your Gemfile"
end

Public Instance Methods

report(report_name) click to toggle source
# File lib/middleman-core/profiling.rb, line 40
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 36
def start
  RubyProf.start
end