Module: Critique::Profiling

Defined in:
lib/critique/profiling.rb

Defined Under Namespace

Classes: Profiler

Class Method Summary collapse

Class Method Details

.profile(base, caller_offset = 0) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/critique/profiling.rb', line 3

def self.profile(base, caller_offset = 0)
  method_name = caller[caller_offset] =~ /`([^']*)'/ && $1
  method_text = label_for(base, method_name)

  Profiler.enter(method_text)
  result = yield # (Profiler)
  Profiler.leave(method_text)

  result
end