Class: RequireProfiler::Printer::CallStack

Inherits:
Base
  • Object
show all
Defined in:
lib/require_profiler/printer/call_stack.rb

Overview

CallStack formatter prints collapsed stacks (Brendan Gregg’s format)

Direct Known Subclasses

JSON

Instance Method Summary collapse

Methods inherited from Base

#finish, #initialize

Constructor Details

This class inherits a constructor from RequireProfiler::Printer::Base

Instance Method Details

#flush(node, parts: []) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/require_profiler/printer/call_stack.rb', line 7

def flush(node, parts: [])
  path = node.path.sub(prefix_stripper, "")
  self_parts = path.split("/")

  parts += self_parts.size.times.map { self_parts.take(_1 + 1).join("/") }
  # We only show self-time, so exclude children
  val = ((node.time - node.children.sum(&:time)) * 1000).round(3)

  output << "#{parts.join(";")} #{val}\n"

  node.children.each { flush(_1, parts:) }
end