Class: Liquid::Profiler::Timing

Inherits:
Object
  • Object
show all
Defined in:
lib/liquid/profiler.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node, partial) ⇒ Timing

Returns a new instance of Timing.



49
50
51
52
53
54
# File 'lib/liquid/profiler.rb', line 49

def initialize(node, partial)
  @code        = node.respond_to?(:raw) ? node.raw : node
  @partial     = partial
  @line_number = node.respond_to?(:line_number) ? node.line_number : nil
  @children    = []
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



47
48
49
# File 'lib/liquid/profiler.rb', line 47

def children
  @children
end

#codeObject (readonly)

Returns the value of attribute code.



47
48
49
# File 'lib/liquid/profiler.rb', line 47

def code
  @code
end

#line_numberObject (readonly)

Returns the value of attribute line_number.



47
48
49
# File 'lib/liquid/profiler.rb', line 47

def line_number
  @line_number
end

#partialObject (readonly)

Returns the value of attribute partial.



47
48
49
# File 'lib/liquid/profiler.rb', line 47

def partial
  @partial
end

Class Method Details

.start(node, partial) ⇒ Object



56
57
58
# File 'lib/liquid/profiler.rb', line 56

def self.start(node, partial)
  new(node, partial).tap(&:start)
end

Instance Method Details

#finishObject



64
65
66
# File 'lib/liquid/profiler.rb', line 64

def finish
  @end_time = Time.now
end

#render_timeObject



68
69
70
# File 'lib/liquid/profiler.rb', line 68

def render_time
  @end_time - @start_time
end

#startObject



60
61
62
# File 'lib/liquid/profiler.rb', line 60

def start
  @start_time = Time.now
end