Sha256: 0fff6dbfe08f3605133cc4cac719a3da710737c7a0496253f0114d2d16d857c2

Contents?: true

Size: 1011 Bytes

Versions: 13

Compression:

Stored size: 1011 Bytes

Contents

require 'benchmark'

module Errplane
  module Rails
    module Benchmarking
      def self.included(base)
        base.send(:alias_method_chain, :perform_action, :instrumentation)
        base.send(:alias_method_chain, :view_runtime, :instrumentation)
        base.send(:alias_method_chain, :active_record_runtime, :instrumentation)
      end

      private
      def perform_action_with_instrumentation
        ms = Benchmark.ms { perform_action_without_instrumentation }
        Errplane.report "controllers/#{params[:controller]}/#{params[:action]}", :value => ms.ceil
      end

      def view_runtime_with_instrumentation
        runtime = view_runtime_without_instrumentation
        Errplane.report "views", :value => runtime.split.last.to_f.ceil
        runtime
      end

      def active_record_runtime_with_instrumentation
        runtime = active_record_runtime_without_instrumentation
        Errplane.report "db", :value => runtime.split.last.to_f.ceil
        runtime
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
errplane-0.5.23 lib/errplane/rails/benchmarking.rb
errplane-0.5.22 lib/errplane/rails/benchmarking.rb
errplane-0.5.21 lib/errplane/rails/benchmarking.rb
errplane-0.5.20 lib/errplane/rails/benchmarking.rb
errplane-0.5.19 lib/errplane/rails/benchmarking.rb
errplane-0.5.18 lib/errplane/rails/benchmarking.rb
errplane-0.5.17 lib/errplane/rails/benchmarking.rb
errplane-0.5.15 lib/errplane/rails/benchmarking.rb
errplane-0.5.14 lib/errplane/rails/benchmarking.rb
errplane-0.5.13 lib/errplane/rails/benchmarking.rb
errplane-0.5.12 lib/errplane/rails/benchmarking.rb
errplane-0.5.11 lib/errplane/rails/benchmarking.rb
errplane-0.5.10 lib/errplane/rails/benchmarking.rb