Ruby 程式設計 / 參考 / 物件 / GC / Profiler
外觀
這是 MRI 1.9 中的一個類
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
請注意,輸出值“呼叫時間(秒)”實際上是在觸發該呼叫之前使用者 CPU 時間的總和——也就是說,sleep 1 的結果將增加 0,而迴圈 1 秒繁忙程式碼的結果將增加 1。