class Speedup::Collectors::RubyprofCollector

Public Class Methods

new(options={}) click to toggle source
Calls superclass method Speedup::Collectors::Collector::new
# File lib/speedup/collectors/rubyprof_collector.rb, line 5
def initialize(options={})
  require 'ruby-prof'
  @results_dir = Rails.root.join('tmp', 'rubyprof')
  Dir.mkdir( @results_dir ) unless File.directory?(@results_dir)
  super
end

Public Instance Methods

end_prof(result_id=nil) click to toggle source
# File lib/speedup/collectors/rubyprof_collector.rb, line 44
def end_prof(result_id=nil)
  result = RubyProf.stop

  Speedup.request.store_event(key, result_id )

  # Print a flat profile to text
  printer = printer_klass.new(result)
  ::File.open(@results_dir.join( Speedup.request.id + result_id.to_s + '.html' ), 'wb') do |file|
    printer.print(file)
  end
end
filter_event?(evt) click to toggle source
# File lib/speedup/collectors/rubyprof_collector.rb, line 36
def filter_event?(evt)
  super || evt.payload[:controller].start_with?('Speedup')
end
parse_options() click to toggle source
# File lib/speedup/collectors/rubyprof_collector.rb, line 12
def parse_options
  @profile_request = !!@options[:profile_request]
end
profile(result_id=nil) { || ... } click to toggle source
# File lib/speedup/collectors/rubyprof_collector.rb, line 56
def profile(result_id=nil, &block)
  start_prof
  yield
  end_prof(next_id)
end
results() click to toggle source

The data results that are inserted at the end of the request for use in deferred placeholders in the Peek the bar.

Returns Hash.

# File lib/speedup/collectors/rubyprof_collector.rb, line 20
def results
  {}
end
setup_subscribes() click to toggle source
# File lib/speedup/collectors/rubyprof_collector.rb, line 24
def setup_subscribes
  if enabled? && @profile_request
    before_request do
      start_prof
    end
    after_request do
      end_prof
    end
  end
end
start_prof() click to toggle source
# File lib/speedup/collectors/rubyprof_collector.rb, line 40
def start_prof
  RubyProf.start
end

Private Instance Methods

next_id() click to toggle source
# File lib/speedup/collectors/rubyprof_collector.rb, line 64
def next_id
  @next_id = @next_id.to_i + 1
end
printer_klass() click to toggle source
# File lib/speedup/collectors/rubyprof_collector.rb, line 68
def printer_klass
  # RubyProf::GraphHtmlPrinter
  RubyProf::CallStackPrinter
end