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.



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

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.



45
46
47
# File 'lib/liquid/profiler.rb', line 45

def children
  @children
end

#codeObject (readonly)

Returns the value of attribute code.



45
46
47
# File 'lib/liquid/profiler.rb', line 45

def code
  @code
end

#line_numberObject (readonly)

Returns the value of attribute line_number.



45
46
47
# File 'lib/liquid/profiler.rb', line 45

def line_number
  @line_number
end

#partialObject (readonly)

Returns the value of attribute partial.



45
46
47
# File 'lib/liquid/profiler.rb', line 45

def partial
  @partial
end

Class Method Details

.start(token, partial) ⇒ Object



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

def self.start(token, partial)
  new(token, partial).tap do |t|
    t.start
  end
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