Open main menu

Wikibooks β

Ruby Programming/Reference/Objects/GC/Profiler

< Ruby Programming‎ | Reference‎ | Objects‎ | GC

This is a class in 1.9 MRI

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

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 it increasing by 0, but a busy loop for one second will result in it increasing by 1.