Module: CiviCrm::Profiling::ClassMethods

Defined in:
lib/civicrm/profiling.rb

Instance Method Summary collapse

Instance Method Details

#profile(&block) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/civicrm/profiling.rb', line 14

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

  block.call

  _profile.dup
ensure
  self._profile = nil
end

#time(entity, action, &block) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/civicrm/profiling.rb', line 24

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

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