class Takwimu::Instruments::Ruby18GC

Public Class Methods

new() click to toggle source
# File lib/takwimu/instruments/ree_gc.rb, line 27
def initialize
  GC.enable_stats
end

Public Instance Methods

instrument!(state, counters, gauges, timers) click to toggle source
# File lib/takwimu/instruments/ree_gc.rb, line 35
def instrument!(state, counters, gauges, timers)
  last = state[:ruby18_gc]
  cur = state[:ruby18_gc] = current

  counters.update \
    :'GC.count'             => cur[:gc_count] - before[:gc_count],
    :'GC.time'              => cur[:gc_time] - before[:gc_time],
    :'GC.memory'            => cur[:gc_memory] - before[:gc_memory],
    :'GC.allocated_objects' => cur[:objects] - before[:objects]

  gauges[:'Objects.live'] = ObjectSpace.live_objects
  gauges[:'GC.growth'] = GC.growth
end
start!(state) click to toggle source
# File lib/takwimu/instruments/ree_gc.rb, line 31
def start!(state)
  state[:ruby18_gc] = current
end

Private Instance Methods

current() click to toggle source
# File lib/takwimu/instruments/ree_gc.rb, line 49
        def current
  {
    :objects   => ObjectSpace.allocated_objects,
    :gc_count  => GC.collections,
    :gc_time   => GC.time,
    :gc_memory => GC.allocated_size
  }
end