Ruby Programming/Reference/Objects/GC/Profiler

(Redirected from Ruby Programming/Reference/Objects/IO/GC/Profiler)

This is a class in 1.9 MRI

GC::Profiler.enable
# ... stuff
GC::Profiler.report # outputs to stdout
# or
report = GC::Profiler.result # a is set to a verbose ascii string
GC::Profiler.disable # stop it
</code>

Note also the existence of GC.count (number of times it has run).

Note that you can get a more report by setting a compiler flag <pre>GC_PROFILE_MORE_DETAIL=1

Note that the outputs "invoke Time(sec)" is actually the sum of user cpu time until that invoke occurred—i.e. a sleep 1 will result it is increasing by 0, but a busy loop for one second will result in it increasing by 1.