Module: GCStats::Yarv

Included in:
GCStats
Defined in:
lib/madvertise/gc_stats.rb

Overview

RUBY 1.9.X-Implementation

Instance Method Summary collapse

Instance Method Details

#clearObject



14
15
16
# File 'lib/madvertise/gc_stats.rb', line 14

def clear
  GC::Profiler.clear
end

#count_allocationsObject



29
30
31
32
# File 'lib/madvertise/gc_stats.rb', line 29

def count_allocations
  allocated_size = GC.respond_to?(:malloc_allocated_size) ? GC.malloc_allocated_size / 1000.0 : 0
  Metriks.histogram('gc_stats.allocated').update(allocated_size)
end

#count_collectionsObject



25
26
27
# File 'lib/madvertise/gc_stats.rb', line 25

def count_collections
  Metriks.histogram('gc_stats.collections').update(GC.count)
end

#count_objectsObject



34
35
36
37
38
# File 'lib/madvertise/gc_stats.rb', line 34

def count_objects
  objects = ObjectSpace.count_objects
  objects = objects[:TOTAL] - objects[:FREE]
  Metriks.histogram('gc_stats.objects').update(objects)
end

#enableObject



10
11
12
# File 'lib/madvertise/gc_stats.rb', line 10

def enable
  GC::Profiler.enable
end

#gatherObject



18
19
20
21
22
23
# File 'lib/madvertise/gc_stats.rb', line 18

def gather
  count_collections
  count_allocations
  count_objects
  Metriks.timer('gc_stats.total_time').update(GC::Profiler.total_time)
end