Class: Liquid::Profiler::Timing

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code: nil, template_name: nil, line_number: nil) ⇒ Timing

Returns a new instance of Timing.



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

def initialize(code: nil, template_name: nil, line_number: nil)
  @code = code
  @template_name = template_name
  @line_number = line_number
  @children = []
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



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

def children
  @children
end

#codeObject (readonly)

Returns the value of attribute code.



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

def code
  @code
end

#line_numberObject (readonly)

Returns the value of attribute line_number.



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

def line_number
  @line_number
end

#template_nameObject (readonly) Also known as: partial

Returns the value of attribute template_name.



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

def template_name
  @template_name
end

#total_timeObject Also known as: render_time

Returns the value of attribute total_time.



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

def total_time
  @total_time
end

Instance Method Details

#self_timeObject



61
62
63
64
65
66
67
68
69
# File 'lib/liquid/profiler.rb', line 61

def self_time
  @self_time ||= begin
    total_children_time = 0.0
    @children.each do |child|
      total_children_time += child.total_time
    end
    @total_time - total_children_time
  end
end