class ActiveSupport::Testing::Performance::Profiler
overridden by each implementation
def create_path_and_open_file(printer_name)
def create_path_and_open_file(printer_name) fname = "#{output_filename}_#{printer_name}.txt" FileUtils.mkdir_p(File.dirname(fname)) File.open(fname, 'wb') do |file| yield(file) end end
def initialize(*args)
def initialize(*args) super @supported = @metric.is_a?(Metrics::WallTime) end
def initialize(*args)
def initialize(*args) super @supported = @metric.is_a?(Metrics::WallTime) end
def initialize(*args)
def initialize(*args) super @supported = @metric.measure_mode rescue false end
def output_filename(printer_class)
def output_filename(printer_class) suffix = case printer_class.name.demodulize when 'FlatProfilePrinter'; 'flat.txt' when 'GraphProfilePrinter'; 'graph.txt' else printer_class.name.sub(/ProfilePrinter$/, '').underscore end "#{super()}_#{suffix}" end
def output_filename(printer_class)
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(/Printer$/, '').underscore end "#{super()}_#{suffix}" end
def record; end
def record; end
def record
def record return unless @supported klasses = full_profile_options[:formats].map { |f| JRuby::Profiler.const_get("#{f.to_s.camelize}ProfilePrinter") }.compact klasses.each do |klass| fname = output_filename(klass) FileUtils.mkdir_p(File.dirname(fname)) file = File.open(fname, 'wb') do |file| klass.new(@data).printProfile(file) end end end
def record
def record return unless @supported if(full_profile_options[:formats].include?(:flat)) create_path_and_open_file(:flat) do |file| @profiler.show(file) end end if(full_profile_options[:formats].include?(:graph)) create_path_and_open_file(:graph) do |file| @profiler.show(file) end end end
def record
def record return unless @supported klasses = full_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, full_profile_options.slice(:min_percent)) end end end
def run; end
def run; end
def run
def run return unless @supported @total = time_with_block do @data = JRuby::Profiler.profile do full_profile_options[:runs].to_i.times { run_test(@metric, :profile) } end end end
def run
def run return unless @supported @profiler = Rubinius::Profiler::Instrumenter.new @total = time_with_block do @profiler.profile(false) do full_profile_options[:runs].to_i.times { run_test(@metric, :profile) } end end end
def run
def run return unless @supported RubyProf.measure_mode = @metric.measure_mode RubyProf.start RubyProf.pause full_profile_options[:runs].to_i.times { run_test(@metric, :profile) } @data = RubyProf.stop @total = @data.threads.sum(0) { |thread| thread.methods.max.total_time } end
def time_with_block
def time_with_block before = Time.now yield Time.now - before end