Sha256: d8aa2ee4f9fefe816805438c3d474940c0e7e8f621ead1d6dd93a0474a4a4315

Contents?: true

Size: 606 Bytes

Versions: 1

Compression:

Stored size: 606 Bytes

Contents

class Flamegraph::Sampler

  def initialize
    @backtraces = []
    @done_samplint = false
  end

  def start
    @backtraces = []
    @done_samplint = false

    t = Thread.current
    @thread = Thread.new do
      begin
        while !@done_sampling
          @backtraces << t.backtrace_locations

          # On my machine using Ruby 2.0 this give me excellent fidelity of stack trace per 1.2ms
          #   with this fidelity analysis becomes very powerful
          sleep 0.0005
        end
      end
    end
  end

  def finish
    @done_sampling = true
    @thread.join
    @backtraces
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flamegraph-0.0.1 lib/flamegraph/sampler.rb