Class: Stackprofiler::Filter::JsTree
- Inherits:
-
Object
- Object
- Stackprofiler::Filter::JsTree
- Defined in:
- lib/stackprofiler/filters/js_tree.rb
Instance Method Summary collapse
- #filter(root, frames) ⇒ Object
-
#initialize(options = {}) ⇒ JsTree
constructor
A new instance of JsTree.
Constructor Details
#initialize(options = {}) ⇒ JsTree
Returns a new instance of JsTree.
4 5 6 |
# File 'lib/stackprofiler/filters/js_tree.rb', line 4 def initialize(={}) end |
Instance Method Details
#filter(root, frames) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/stackprofiler/filters/js_tree.rb', line 8 def filter root, frames addrs = root.content[:addrs] name = addrs.first.to_i frame = frames[name] escaped = addrs.map do |addr| this_frame = frames[addr.to_i] this_name = CGI::escapeHTML(this_frame[:name]) "#{this_name} (<b>#{this_frame[:samples]}</b>)" end text = escaped.join("<br> ↳ ") sorted_children = root.children.sort_by do |child| addr = child.content[:addrs].first.to_i frame = frames[addr] frame[:samples] end.reverse children = sorted_children.map { |n| filter(n, frames) } open = root.content.has_key?(:open) ? root.content[:open] : frame[:total_samples] > 100 {text: text, state: {opened: open}, children: children, icon: false, data: {addrs: addrs}} end |