Sha256: 49ae88f68f71960abc9ad095d0f77d52068f4eded1dc5e28fb43983df1d2a085

Contents?: true

Size: 519 Bytes

Versions: 11

Compression:

Stored size: 519 Bytes

Contents

require "benchmark"

module CiviCrm
  module Profiling
    extend ActiveSupport::Concern

    included do
      private

      mattr_accessor :_profile
    end

    module ClassMethods
      def profile(&block)
        self._profile = []

        block.call

        _profile.dup
      ensure
        self._profile = nil
      end

      def time(entity, action, &block)
        time = Benchmark.realtime(&block)

        if _profile
          _profile << [entity, action, time]
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
civicrm-1.3.7 lib/civicrm/profiling.rb
civicrm-1.3.6 lib/civicrm/profiling.rb
civicrm-1.3.5 lib/civicrm/profiling.rb
civicrm-1.3.4 lib/civicrm/profiling.rb
civicrm-1.3.3 lib/civicrm/profiling.rb
civicrm-1.3.2 lib/civicrm/profiling.rb
civicrm-1.3.1 lib/civicrm/profiling.rb
civicrm-1.2.5 lib/civicrm/profiling.rb
civicrm-1.2.2 lib/civicrm/profiling.rb
civicrm-1.2.1 lib/civicrm/profiling.rb
civicrm-1.2.0 lib/civicrm/profiling.rb