# File lib/active_support/testing/performance.rb, line 192 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
# File lib/active_support/testing/performance.rb, line 184 def report if @supported super else '%20s: unsupported' % @metric.name end end
# File lib/active_support/testing/performance.rb, line 173 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.max.total_time } end
# File lib/active_support/testing/performance.rb, line 207 def output_filename(printer_class) suffix = case printer_class.name.demodulize when 'FlatPrinter'; 'flat.txt' when 'FlatPrinterWithLineNumbers'; 'flat_line_numbers.txt' when 'GraphPrinter'; 'graph.txt' when 'GraphHtmlPrinter'; 'graph.html' when 'GraphYamlPrinter'; 'graph.yml' when 'CallTreePrinter'; 'tree.txt' when 'CallStackPrinter'; 'stack.html' when 'DotPrinter'; 'graph.dot' else printer_class.name.sub(%rPrinter$/, '').underscore end "#{super()}_#{suffix}" end
# File lib/active_support/testing/performance.rb, line 168 def initialize(*args) super @supported = @metric.measure_mode rescue false end