Class: Critique::Profiling::Profiler

Inherits:
Object
  • Object
show all
Defined in:
lib/critique/profiling.rb

Class Method Summary collapse

Class Method Details

.enter(label, interests) ⇒ Object



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

def enter(label, interests)
  padding(:+)

  before = stack.push(system_usage.push(label)).last
  found  = (interests.map { |mod| [mod, ObjectSpace.each_object(mod).count].join(':') })

  info(([label, '-->', filler(label)] + pretty(before, found)).join(' '))
end

.info(message) ⇒ Object



20
21
22
# File 'lib/critique/profiling.rb', line 20

def info(message)
  Critique.logger.info(['X', padding, message].join)
end

.leave(label, interests) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/critique/profiling.rb', line 33

def leave(label, interests)
  found  = (interests.map { |mod| [mod, ObjectSpace.each_object(mod).count].join(':') })
  before = stack.pop
  after  = system_usage

  info(([label, '<--', filler(label)] + pretty(after, found)).join(' '))

  padding(:-)
end