Sha256: 8d1f6a32a6fd4f37593b29346bb5fc25b4d936c67e229e402ce3bbc11bd88c98

Contents?: true

Size: 1.11 KB

Versions: 60

Compression:

Stored size: 1.11 KB

Contents

module RailsOps
  class Profiler::Node
    def initialize(object_id, description = nil, parent = nil)
      @object_id = object_id
      @description = description
      @parent = parent
      parent.add_child(self) if parent
      @children = []
      @erroneous = false
      @t_start = Time.now
    end

    attr_reader :parent
    attr_reader :description

    def finish_measure
      @t_stop = Time.now
    end

    def erroneous!
      @erroneous = true
    end

    def erroneous?
      @erroneous
    end

    def t_self
      t_total - t_kids
    end

    def t_kids
      @children.map(&:t_total).inject(:+) || 0
    end

    def t_total
      return nil unless @t_stop
      (@t_stop - @t_start).to_f
    end

    def t_self_s
      t_self
    end

    def t_kids_s
      t_kids
    end

    def t_total_s
      t_total
    end

    def t_self_ms
      t_self * 1000
    end

    def t_kids_ms
      t_kids * 1000
    end

    def t_total_ms
      t_total * 1000
    end

    def free
      ::RailsOps::Profiler.forget(@object_id) unless parent
    end

    def add_child(child)
      @children << child
    end
  end
end

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
rails_ops-1.0.21 lib/rails_ops/profiler/node.rb
rails_ops-1.0.20 lib/rails_ops/profiler/node.rb
rails_ops-1.0.19 lib/rails_ops/profiler/node.rb
rails_ops-1.0.18 lib/rails_ops/profiler/node.rb
rails_ops-1.0.17 lib/rails_ops/profiler/node.rb
rails_ops-1.0.16 lib/rails_ops/profiler/node.rb
rails_ops-1.0.15 lib/rails_ops/profiler/node.rb
rails_ops-1.0.14 lib/rails_ops/profiler/node.rb
rails_ops-1.0.13 lib/rails_ops/profiler/node.rb
rails_ops-1.0.12 lib/rails_ops/profiler/node.rb
rails_ops-1.0.11 lib/rails_ops/profiler/node.rb
rails_ops-1.0.10 lib/rails_ops/profiler/node.rb
rails_ops-1.0.9 lib/rails_ops/profiler/node.rb
rails_ops-1.0.7 lib/rails_ops/profiler/node.rb
rails_ops-1.0.6 lib/rails_ops/profiler/node.rb
rails_ops-1.0.5 lib/rails_ops/profiler/node.rb
rails_ops-1.0.4 lib/rails_ops/profiler/node.rb
rails_ops-1.0.3 lib/rails_ops/profiler/node.rb
rails_ops-1.0.2 lib/rails_ops/profiler/node.rb
rails_ops-1.0.1 lib/rails_ops/profiler/node.rb