Sha256: 1e11abf9ddce2d07600a28e286afa0de69f5dcf91a8608b7d4e598c9165b9a5c
Contents?: true
Size: 1.74 KB
Versions: 2
Compression:
Stored size: 1.74 KB
Contents
require 'ruby-prof' module ActionController #:nodoc: # The ruby-prof module times the performance of actions and reports to the logger. If the Active Record # package has been included, a separate timing section for database calls will be added as well. module Profiling #:nodoc: def self.included(base) base.class_eval do alias_method_chain :perform_action, :profiling end end def perform_action_with_profiling if not logger or not logger.level == Logger::DEBUG perform_action_without_profiling else result = RubyProf.profile do perform_action_without_profiling end output = StringIO.new output << " [#{complete_request_uri rescue "unknown"}]" output << "\n\n" # Create a flat printer printer = RubyProf::FlatPrinter.new(result) # Skip anything less than 1% - which is a lot of # stuff in Rails. Don't print the source file # its too noisy. printer.print(output, {:min_percent => 1, :print_file => false}) logger.info(output.string) ## Example for Graph html printer #printer = RubyProf::GraphHtmlPrinter.new(result) #File.open('c:/temp/request.html', 'w') do |file| #printer.print(file, {:min_percent => 1, #:print_file => true}) #end ## Used for KCacheGrind visualizations #printer = RubyProf::CallTreePrinter.new(result) #File.open('c:/temp/callgrind.out', 'w') do |file| #printer.print(file, {:min_percent => 1, #:print_file => true}) #end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruby-prof-0.5.0-mswin32 | lib/ruby-prof/rails_plugin/ruby-prof/lib/profiling.rb |
ruby-prof-0.5.0 | lib/ruby-prof/rails_plugin/ruby-prof/lib/profiling.rb |