Class: Stackprofiler::Filter::BuildTree
- Inherits:
-
Object
- Object
- Stackprofiler::Filter::BuildTree
- Defined in:
- lib/stackprofiler/filters/build_tree.rb
Instance Method Summary collapse
- #filter(run, run2) ⇒ Object
-
#initialize(options = {}) ⇒ BuildTree
constructor
A new instance of BuildTree.
- #inverted? ⇒ Boolean
- #iterate(stack, &blk) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ BuildTree
Returns a new instance of BuildTree.
4 5 6 |
# File 'lib/stackprofiler/filters/build_tree.rb', line 4 def initialize(={}) @options = end |
Instance Method Details
#filter(run, run2) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/stackprofiler/filters/build_tree.rb', line 8 def filter run, run2 stacks = run.stacks root = StandardWarning.disable { Tree::TreeNode.new '(Root)', {addrs: [], open: true} } stacks.each do |stack| prev = root iterate stack do |addr| # nobody likes hacks, but this halved the page rendering time node = prev.instance_variable_get(:@children_hash)[addr] if node.nil? hash = {count: 0, addrs: [addr]} node = StandardWarning.disable { Tree::TreeNode.new(addr, hash) } prev << node end node.content[:count] +=1 prev = node end end if inverted? root.children.each {|n| n.content[:open] = false } end root end |
#inverted? ⇒ Boolean
35 36 37 |
# File 'lib/stackprofiler/filters/build_tree.rb', line 35 def inverted? @options[:invert] end |
#iterate(stack, &blk) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/stackprofiler/filters/build_tree.rb', line 39 def iterate stack, &blk if inverted? stack.reverse_each &blk else stack.each &blk end end |