Class: Trashed::Instruments::RubyGC

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

Constant Summary collapse

MEASUREMENTS =
{
  :count => :'GC.count'
}
RUBY_2X_MEASUREMENTS =
{
  :major_gc_count => :'GC.major_count',
  :minor_gc_count => :'GC.minor_gc_count'
}

Instance Method Summary collapse

Instance Method Details

#measure(state, timings, gauges) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/trashed/instruments/ruby_gc.rb', line 38

def measure(state, timings, gauges)
  gc = GC.stat
  before = state[:ruby_gc]

  MEASUREMENTS.each do |stat, metric|
    timings[metric] = gc[stat] - before[stat] if gc.include? stat
  end

  gauges.concat gc.map { |k, v| [ :"GC.#{k}", v ] }
end

#start(state, timings, gauges) ⇒ Object



4
5
6
# File 'lib/trashed/instruments/ruby_gc.rb', line 4

def start(state, timings, gauges)
  state[:ruby_gc] = GC.stat
end