Module: DebugTimer

Defined in:
lib/debug_timer.rb,
lib/debug_timer/node.rb,
lib/debug_timer/config.rb,
lib/debug_timer/logger.rb,
lib/debug_timer/version.rb,
lib/debug_timer/node_printer.rb

Defined Under Namespace

Classes: Node, NodePrinter

Constant Summary collapse

VERSION =
"0.1.0"
@@object_allocations =
false

Class Method Summary collapse

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (DebugTimer)

    the object that the method was called on



4
5
6
# File 'lib/debug_timer/config.rb', line 4

def self.configure
  yield self
end

.loggerObject



6
7
8
# File 'lib/debug_timer/logger.rb', line 6

def self.logger
  @@logger ||= Logger.new($stdout)
end

.logger=(logger) ⇒ Object



2
3
4
# File 'lib/debug_timer/logger.rb', line 2

def self.logger=(logger)
  @@logger = logger
end

.object_allocations=(object_allocations) ⇒ Object



8
9
10
# File 'lib/debug_timer/config.rb', line 8

def self.object_allocations=(object_allocations)
  @@object_allocations = object_allocations
end

.object_allocations?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/debug_timer/config.rb', line 12

def self.object_allocations?
  @@object_allocations
end

.start(name = '---', &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/debug_timer.rb', line 9

def self.start(name = '---', &block)
  parent = @current_node

  @current_node = Node.new(name)
  result = yield
  @current_node.stop()

  if parent
    parent.children << @current_node
  else
    print_tree(@current_node)
  end

  result
  ensure
    @current_node = parent
end