Sha256: 50b8231a9a73fd45706bf7db14d7a32975d31b5cc5a6ac0e495d1d8e808a2e03

Contents?: true

Size: 830 Bytes

Versions: 1

Compression:

Stored size: 830 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

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

      def add(rendering)
        @children << rendering
        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.0,
            'exclusive' => exclusive_time * 1000.0,
            'children' => children.map(&:results)
          }
        }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
remnant-0.3.0 lib/remnant/template/rendering.rb