Class: Stackprofiler::Filter::JsTree
- Inherits:
-
Object
- Object
- Stackprofiler::Filter::JsTree
- Defined in:
- lib/stackprofiler/filters/js_tree.rb
Instance Method Summary collapse
- #filter(root, run) ⇒ 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, run) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/stackprofiler/filters/js_tree.rb', line 8 def filter root, run addrs = root.content[:addrs] name = addrs.first frames = run.profile[:frames] frame = frames[name] escaped = addrs.map do |addr| this_frame = frames[addr] this_name = CGI::escapeHTML(this_frame[:name]) "#{this_name} (<b>#{this_frame[:samples]}</b>)" end text = escaped.join("<br> ↳ ").presence || root.name sorted_children = root.children.sort_by do |child| addr = child.content[:addrs].first cframe = frames[addr] cframe[:samples] end.reverse children = sorted_children.map { |n| filter(n, run) } 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 |