Class: Flamegraph::Sampler
- Inherits:
-
Object
- Object
- Flamegraph::Sampler
- Defined in:
- lib/flamegraph/sampler.rb
Class Method Summary collapse
Class Method Details
.collect(fidelity = 0.5) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/flamegraph/sampler.rb', line 2 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 |