class Trashed::Instruments::Ruby18GC

Public Class Methods

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

Public Instance Methods

measure(state, timings, gauges) click to toggle source
# File lib/trashed/instruments/ree_gc.rb, line 16
def measure(state, timings, gauges)
  before = state[:ruby18_gc]

  timings.update \
    :'GC.count'             => GC.collections - before[:gc_count],
    :'GC.time'              => GC.time - before[:gc_time],
    :'GC.memory'            => GC.allocated_size - before[:gc_memory],
    :'GC.allocated_objects' => ObjectSpace.allocated_objects - before[:objects]

  gauges << [ :'Objects.live',  ObjectSpace.live_objects ]
  gauges << [ :'GC.growth',     GC.growth ]
end
start(state, timings, gauges) click to toggle source
# File lib/trashed/instruments/ree_gc.rb, line 8
def start(state, timings, gauges)
  state[:ruby18_gc] = {
    :objects   => ObjectSpace.allocated_objects,
    :gc_count  => GC.collections,
    :gc_time   => GC.time,
    :gc_memory => GC.allocated_size }
end