Module: Kernel

Defined in:
lib/singed/kernel_ext.rb

Instance Method Summary collapse

Instance Method Details

#flamegraph(label = nil, open: true, ignore_gc: false, interval: 1000, io: $stdout) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/singed/kernel_ext.rb', line 2

def flamegraph(label = nil, open: true, ignore_gc: false, interval: 1000, io: $stdout, &)
  fg = Singed::Flamegraph.new(label: label, ignore_gc: ignore_gc, interval: interval)
  result = fg.record(&)
  fg.save

  if open
    # use npx, so we don't have to add it as a dependency
    io.puts "🔥📈 #{"Captured flamegraph, opening with".colorize(:bold).colorize(:red)}: #{fg.open_command}"
    fg.open
  else
    io.puts "🔥📈 #{"Captured flamegraph to file".colorize(:bold).colorize(:red)}: #{fg.filename}"
  end

  result
end