class Benchin::Wrap::Report::Node
@api private
Attributes
calls[R]
name[R]
nested[R]
total_seconds[R]
Public Class Methods
new(name)
click to toggle source
# File lib/benchin/wrap/report/node.rb, line 11 def initialize(name) @name = name @calls = 0 @total_seconds = 0.0 @nested = {} end
Public Instance Methods
add_call(seconds)
click to toggle source
# File lib/benchin/wrap/report/node.rb, line 19 def add_call(seconds) @child_seconds = nil @calls += 1 @total_seconds += seconds end
child_seconds()
click to toggle source
# File lib/benchin/wrap/report/node.rb, line 40 def child_seconds child_nodes = nested.values @child_seconds ||= child_nodes.map(&:total_seconds).sum.to_f end
self_seconds()
click to toggle source
# File lib/benchin/wrap/report/node.rb, line 36 def self_seconds total_seconds - child_seconds end
to_h()
click to toggle source
# File lib/benchin/wrap/report/node.rb, line 25 def to_h { name: name, calls: calls, total_seconds: total_seconds, self_seconds: self_seconds, child_seconds: child_seconds, nested: nested.values.map(&:to_h) } end