Class Index [+]

Quicksearch

ActiveSupport::Testing::Performance::Profiler

Public Class Methods

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

Public Instance Methods

record() click to toggle source
     # File lib/active_support/testing/performance.rb, line 192
192:           def record
193:             return unless @supported
194: 
195:             klasses = profile_options[:formats].map { |f| RubyProf.const_get("#{f.to_s.camelize}Printer") }.compact
196: 
197:             klasses.each do |klass|
198:               fname = output_filename(klass)
199:               FileUtils.mkdir_p(File.dirname(fname))
200:               File.open(fname, 'wb') do |file|
201:                 klass.new(@data).print(file, profile_options.slice(:min_percent))
202:               end
203:             end
204:           end
report() click to toggle source
     # File lib/active_support/testing/performance.rb, line 184
184:           def report
185:             if @supported
186:               super
187:             else
188:               '%20s: unsupported' % @metric.name
189:             end
190:           end
run() click to toggle source
     # File lib/active_support/testing/performance.rb, line 173
173:           def run
174:             return unless @supported
175: 
176:             RubyProf.measure_mode = @metric.measure_mode
177:             RubyProf.start
178:             RubyProf.pause
179:             profile_options[:runs].to_i.times { run_test(@metric, :profile) }
180:             @data = RubyProf.stop
181:             @total = @data.threads.values.sum(0) { |method_infos| method_infos.max.total_time }
182:           end

Protected Instance Methods

output_filename(printer_class) click to toggle source
     # File lib/active_support/testing/performance.rb, line 207
207:             def output_filename(printer_class)
208:               suffix =
209:                 case printer_class.name.demodulize
210:                   when 'FlatPrinter';                 'flat.txt'
211:                   when 'FlatPrinterWithLineNumbers';  'flat_line_numbers.txt'
212:                   when 'GraphPrinter';                'graph.txt'
213:                   when 'GraphHtmlPrinter';            'graph.html'
214:                   when 'GraphYamlPrinter';            'graph.yml'
215:                   when 'CallTreePrinter';             'tree.txt'
216:                   when 'CallStackPrinter';            'stack.html'
217:                   when 'DotPrinter';                  'graph.dot'
218:                   else printer_class.name.sub(/Printer$/, '').underscore
219:                 end
220: 
221:               "#{super()}_#{suffix}"
222:             end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.