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(token, partial) ⇒ Timing

Returns a new instance of Timing.



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

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

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



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

def children
  @children
end

#codeObject (readonly)

Returns the value of attribute code.



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

def code
  @code
end

#line_numberObject (readonly)

Returns the value of attribute line_number.



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

def line_number
  @line_number
end

#partialObject (readonly)

Returns the value of attribute partial.



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

def partial
  @partial
end

Class Method Details

.start(token, partial) ⇒ Object



57
58
59
60
61
# File 'lib/liquid/profiler.rb', line 57

def self.start(token, partial)
  new(token, partial).tap do |t|
    t.start
  end
end

Instance Method Details

#finishObject



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

def finish
  @end_time = Time.now
end

#render_timeObject



71
72
73
# File 'lib/liquid/profiler.rb', line 71

def render_time
  @end_time - @start_time
end

#startObject



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

def start
  @start_time = Time.now
end