Class/Module Index [+]

Quicksearch

ActiveSupport::Testing::Performance::Profiler

Public Class Methods

new(*args) click to toggle source
# File lib/active_support/testing/performance.rb, line 165
def initialize(*args)
  super
  @supported = @metric.measure_mode rescue false
end

Public Instance Methods

record() click to toggle source
# File lib/active_support/testing/performance.rb, line 189
def record
  return unless @supported

  klasses = profile_options[:formats].map { |f| RubyProf.const_get("#{f.to_s.camelize}Printer") }.compact

  klasses.each do |klass|
    fname = output_filename(klass)
    FileUtils.mkdir_p(File.dirname(fname))
    File.open(fname, 'wb') do |file|
      klass.new(@data).print(file, profile_options.slice(:min_percent))
    end
  end
end
report() click to toggle source
# File lib/active_support/testing/performance.rb, line 181
def report
  if @supported
    super
  else
    '%20s: unsupported' % @metric.name
  end
end
run() click to toggle source
# File lib/active_support/testing/performance.rb, line 170
def run
  return unless @supported

  RubyProf.measure_mode = @metric.measure_mode
  RubyProf.start
  RubyProf.pause
  profile_options[:runs].to_i.times { run_test(@metric, :profile) }
  @data = RubyProf.stop
  @total = @data.threads.values.sum(0) { |method_infos| method_infos.sort.last.total_time }
end

Protected Instance Methods

output_filename(printer_class) click to toggle source
# File lib/active_support/testing/performance.rb, line 204
def output_filename(printer_class)
  suffix =
    case printer_class.name.demodulize
      when 'FlatPrinter'; 'flat.txt'
      when 'GraphPrinter'; 'graph.txt'
      when 'GraphHtmlPrinter'; 'graph.html'
      when 'CallTreePrinter'; 'tree.txt'
      else printer_class.name.sub(/Printer$/, '').underscore
    end

  "#{super()}_#{suffix}"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.