Class: Middleman::Profiling::RubyProfProfiler
- Inherits:
-
Object
- Object
- Middleman::Profiling::RubyProfProfiler
- Defined in:
- lib/middleman-core/profiling.rb
Overview
A profiler that uses ruby-prof
Instance Method Summary collapse
-
#initialize ⇒ RubyProfProfiler
constructor
A new instance of RubyProfProfiler.
- #report(report_name) ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize ⇒ RubyProfProfiler
Returns a new instance of RubyProfProfiler.
33 34 35 36 37 38 39 |
# File 'lib/middleman-core/profiling.rb', line 33 def initialize begin require 'ruby-prof' rescue LoadError raise "To use the --profile option, you must add the 'ruby-prof' gem to your Gemfile" end end |
Instance Method Details
#report(report_name) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# 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 ⇒ Object
41 42 43 |
# File 'lib/middleman-core/profiling.rb', line 41 def start RubyProf.start end |