Class: DevelopmentProfiler

Inherits:
Object
  • Object
show all
Defined in:
lib/development_profiler.rb

Class Method Summary collapse

Class Method Details

.prof(file_name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/development_profiler.rb', line 5

def self.prof(file_name)
  RubyProf.start
  yield
  results = RubyProf.stop

  base_path = 'tmp'

  # Print a flat profile to text
  File.open "#{base_path}/#{file_name}-graph.html", 'w' do |file|
    RubyProf::GraphHtmlPrinter.new(results).print(file)
  end

  File.open "#{base_path}/#{file_name}-flat.txt", 'w' do |file|
    # RubyProf::FlatPrinter.new(results).print(file)
    RubyProf::FlatPrinterWithLineNumbers.new(results).print(file)
  end

  File.open "#{base_path}/#{file_name}-stack.html", 'w' do |file|
    RubyProf::CallStackPrinter.new(results).print(file)
  end
end