Sha256: bca6e31f0edec087708292852665efa5a858e1a73a78ed1b4469cbe68c06bbde

Contents?: true

Size: 523 Bytes

Versions: 10

Compression:

Stored size: 523 Bytes

Contents

class Flamegraph::Sampler
  def self.collect(fidelity=0.5)
    backtraces = []
    done = false

    t = Thread.current
    thread = Thread.new do
      until done
        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 (fidelity / 1000.0)
      end
    end

    begin
      yield
    ensure
      done = true
      thread.join
    end

    backtraces
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
flamegraph-0.9.5 lib/flamegraph/sampler.rb
flamegraph-0.1.0 lib/flamegraph/sampler.rb
flamegraph-0.0.9 lib/flamegraph/sampler.rb
flamegraph-0.0.8 lib/flamegraph/sampler.rb
flamegraph-0.0.7 lib/flamegraph/sampler.rb
flamegraph-0.0.6 lib/flamegraph/sampler.rb
flamegraph-0.0.5 lib/flamegraph/sampler.rb
flamegraph-0.0.4 lib/flamegraph/sampler.rb
flamegraph-0.0.3 lib/flamegraph/sampler.rb
flamegraph-0.0.2 lib/flamegraph/sampler.rb