Sha256: 06ca81b9f78d2506c1989ec371667b5c3e5cf652716af5df4e0f4c5aede556d5

Contents?: true

Size: 498 Bytes

Versions: 3

Compression:

Stored size: 498 Bytes

Contents

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

3 entries across 3 versions & 1 rubygems

Version Path
civicrm-1.1.1 lib/civicrm/profiling.rb
civicrm-1.1.0 lib/civicrm/profiling.rb
civicrm-1.0.7 lib/civicrm/profiling.rb