Class: ProfilerRails::Profiler

Inherits:
Object
  • Object
show all
Defined in:
lib/profiler_rails.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
# File 'lib/profiler_rails.rb', line 5

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

  File.open "#{Rails.root}/tmp/#{directory_name}/#{file_name}-graph.html", 'w' do |file|
    RubyProf::GraphHtmlPrinter.new(results).print(file)
  end

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

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