Methods
Public Class methods
[ show source ]
# File activesupport/lib/active_support/testing/performance.rb, line 167 167: def initialize(*args) 168: super 169: @supported = @metric.measure_mode rescue false 170: end
Public Instance methods
[ show source ]
# File activesupport/lib/active_support/testing/performance.rb, line 191 191: def record 192: return unless @supported 193: 194: klasses = profile_options[:formats].map { |f| RubyProf.const_get("#{f.to_s.camelize}Printer") }.compact 195: 196: klasses.each do |klass| 197: fname = output_filename(klass) 198: FileUtils.mkdir_p(File.dirname(fname)) 199: File.open(fname, 'wb') do |file| 200: klass.new(@data).print(file, profile_options.slice(:min_percent)) 201: end 202: end 203: end
[ show source ]
# File activesupport/lib/active_support/testing/performance.rb, line 183 183: def report 184: if @supported 185: super 186: else 187: '%20s: unsupported' % @metric.name 188: end 189: end
[ show source ]
# File activesupport/lib/active_support/testing/performance.rb, line 172 172: def run 173: return unless @supported 174: 175: RubyProf.measure_mode = @metric.measure_mode 176: RubyProf.start 177: RubyProf.pause 178: profile_options[:runs].to_i.times { run_test(@metric, :profile) } 179: @data = RubyProf.stop 180: @total = @data.threads.values.sum(0) { |method_infos| method_infos.sort.last.total_time } 181: end
Protected Instance methods
[ show source ]
# File activesupport/lib/active_support/testing/performance.rb, line 206 206: def output_filename(printer_class) 207: suffix = 208: case printer_class.name.demodulize 209: when 'FlatPrinter'; 'flat.txt' 210: when 'GraphPrinter'; 'graph.txt' 211: when 'GraphHtmlPrinter'; 'graph.html' 212: when 'CallTreePrinter'; 'tree.txt' 213: else printer_class.name.sub(/Printer$/, '').underscore 214: end 215: 216: "#{super()}_#{suffix}" 217: end