Sha256: f74c8e5376109ad3509ba24d493c27685cd7debfc138dc24990565bcc83a2cb5

Contents?: true

Size: 557 Bytes

Versions: 1

Compression:

Stored size: 557 Bytes

Contents

require "json"
require "fast_stack"
require "flamegraph/version"
require "flamegraph/renderer"

module Flamegraph
  def self.generate(filename=nil, opts = {})
    fidelity = opts[:fidelity]  || 0.5

    backtraces = FastStack.profile(fidelity) do
      yield
    end

    embed_resources = filename && !opts.key?(:embed_resources)

    renderer = Flamegraph::Renderer.new(backtraces)
    rendered = renderer.graph_html(embed_resources)

    if filename
      File.open(filename,"w") do |f|
        f.write(rendered)
      end
    end
    rendered
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flamegraph-0.0.4 lib/flamegraph.rb