Sha256: 09b6fe7f3b17e1020fc729d22b5c629a54bd5c1851e64d9330b0395c77b84281

Contents?: true

Size: 938 Bytes

Versions: 21

Compression:

Stored size: 938 Bytes

Contents

class Remnant
  class Template
    class Rendering
      attr_accessor :name
      attr_accessor :start_time
      attr_accessor :end_time
      attr_accessor :parent
      attr_accessor :children
      attr_accessor :depth

      def initialize(name)
        @name = name
        @children = []
        @depth = 0
      end

      def add(rendering)
        @children << rendering
        rendering.depth = depth + 1
        rendering.parent = self
      end

      def time
        @end_time - @start_time
      end

      def exclusive_time
        time - child_time
      end

      def child_time
        children.inject(0.0) {|memo, c| memo + c.time}
      end

      def results
        @results ||= {name.to_s => {
            'time' => time * 1000,
            'exclusive' => exclusive_time * 1000,
            'depth' => depth,
            'children' => children.map(&:results)
          }
        }
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
remnant-1.0.0 lib/remnant/template/rendering.rb
remnant-0.4.10 lib/remnant/template/rendering.rb
remnant-0.4.9 lib/remnant/template/rendering.rb
remnant-0.4.8 lib/remnant/template/rendering.rb
remnant-0.4.7 lib/remnant/template/rendering.rb
remnant-0.4.6 lib/remnant/template/rendering.rb
remnant-0.4.5 lib/remnant/template/rendering.rb
remnant-0.9.5 lib/remnant/template/rendering.rb
remnant-0.9.4 lib/remnant/template/rendering.rb
remnant-0.4.4 lib/remnant/template/rendering.rb
remnant-0.9.3 lib/remnant/template/rendering.rb
remnant-0.9.2 lib/remnant/template/rendering.rb
remnant-0.9.1 lib/remnant/template/rendering.rb
remnant-0.9.0 lib/remnant/template/rendering.rb
remnant-0.4.3 lib/remnant/template/rendering.rb
remnant-0.4.2 lib/remnant/template/rendering.rb
remnant-0.4.1 lib/remnant/template/rendering.rb
remnant-0.4.0 lib/remnant/template/rendering.rb
remnant-0.3.3 lib/remnant/template/rendering.rb
remnant-0.3.2 lib/remnant/template/rendering.rb