Class: Trashed::Instruments::RubyGCProfiler

Inherits:
Object
  • Object
show all
Defined in:
lib/trashed/instruments/ruby_gc_profiler.rb

Instance Method Summary collapse

Instance Method Details

#measure(state, timings, gauges, captured = :GC) ⇒ Object

Captures in-band GC time and stats.



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/trashed/instruments/ruby_gc_profiler.rb', line 11

def measure(state, timings, gauges, captured = :GC)
  timings[:"#{captured}.time"] ||= 1000 * GC::Profiler.total_time

  if GC::Profiler.respond_to? :raw_data
    timings[:"#{captured}.count"] ||= GC::Profiler.raw_data.size
    timings[:'GC.interval'] = GC::Profiler.raw_data.map { |data| 1000 * data[:GC_INVOKE_TIME] }
  end

  # Clears .total_time and .raw_data
  GC::Profiler.clear
end

#start(state, timings, gauges) ⇒ Object

Captures out-of-band GC time and stats.



5
6
7
8
# File 'lib/trashed/instruments/ruby_gc_profiler.rb', line 5

def start(state, timings, gauges)
  GC::Profiler.enable
  measure state, timings, gauges, :OOBGC
end