Sha256: 9a9ff026ac7948d4c1497eeb2cf0d61a9ce0414153faae53e8437e4ce97ced36

Contents?: true

Size: 839 Bytes

Versions: 43

Compression:

Stored size: 839 Bytes

Contents

require "ruby-prof"

module Ramaze
  class Dispatcher
    class ActionProfiler < Action
      def self.call(path)
        if RubyProf.running?
          super
        else
          result = RubyProf.profile { super }
          output = StringIO.new
          printer = RubyProf::FlatPrinter.new(result)
          options = {
            :min_percent => Contrib::Profiling.trait[:min_percent],
            :print_file => false
          }
          printer.print(output, options)
          output.string.split("\n").each do |line|
            Log.info(line)
          end
        end
      end
    end
  end

  module Contrib
    class Profiling
      trait :min_percent => 1

      def self.startup
        Dispatcher::FILTER.delete(Dispatcher::Action)
        Dispatcher::FILTER << Dispatcher::ActionProfiler
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 5 rubygems

Version Path
Pistos-ramaze-2008.09 lib/ramaze/contrib/profiling.rb
Pistos-ramaze-2008.12 lib/ramaze/contrib/profiling.rb
Pistos-ramaze-2009.01 lib/ramaze/contrib/profiling.rb
Pistos-ramaze-2009.02 lib/ramaze/contrib/profiling.rb
Pistos-ramaze-2009.04.08 lib/ramaze/contrib/profiling.rb
Pistos-ramaze-2009.06.12 lib/ramaze/contrib/profiling.rb
manveru-ramaze-2008.09 lib/ramaze/contrib/profiling.rb
manveru-ramaze-2008.10 lib/ramaze/contrib/profiling.rb
manveru-ramaze-2008.12 lib/ramaze/contrib/profiling.rb
manveru-ramaze-2009.01 lib/ramaze/contrib/profiling.rb
manveru-ramaze-2009.04.01 lib/ramaze/contrib/profiling.rb
manveru-ramaze-2009.04.08 lib/ramaze/contrib/profiling.rb
manveru-ramaze-2009.04.18 lib/ramaze/contrib/profiling.rb
manveru-ramaze-2009.04.22 lib/ramaze/contrib/profiling.rb
manveru-ramaze-2009.04 lib/ramaze/contrib/profiling.rb
manveru-ramaze-2009.05.08 lib/ramaze/contrib/profiling.rb
manveru-ramaze-2009.05 lib/ramaze/contrib/profiling.rb
manveru-ramaze-2009.06.04 lib/ramaze/contrib/profiling.rb
manveru-ramaze-2009.06.12 lib/ramaze/contrib/profiling.rb
manveru-ramaze-2009.06 lib/ramaze/contrib/profiling.rb