Class: Trashed::Instruments::Ruby18GC
- Inherits:
-
Object
- Object
- Trashed::Instruments::Ruby18GC
- Defined in:
- lib/trashed/instruments/ree_gc.rb
Instance Method Summary collapse
-
#initialize ⇒ Ruby18GC
constructor
A new instance of Ruby18GC.
- #measure(state, timings, gauges) ⇒ Object
- #start(state, timings, gauges) ⇒ Object
Constructor Details
#initialize ⇒ Ruby18GC
Returns a new instance of Ruby18GC.
4 5 6 |
# File 'lib/trashed/instruments/ree_gc.rb', line 4 def initialize GC.enable_stats end |
Instance Method Details
#measure(state, timings, gauges) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# 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) ⇒ Object
8 9 10 11 12 13 14 |
# 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 |