Module: Critique::Profiling

Defined in:
lib/critique/profiling.rb

Defined Under Namespace

Classes: Profiler

Class Method Summary collapse

Class Method Details

.profile(*args) ⇒ Object



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

def self.profile(*args)
  base      = args.shift
  offset    = args.shift
  interests = args

  method_name = caller[offset] =~ /`([^']*)'/ && $1
  method_text = label_for(base, method_name)

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

  result
end