跳轉到內容

Ruby 程式設計/參考/物件/GC/Profiler

從維基百科,開放的世界,開放的書籍
(重定向自 Ruby 程式設計/參考/物件/IO/GC/Profiler)

這是 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

請注意,輸出“呼叫時間(秒)”實際上是到呼叫發生為止使用者 CPU 時間的總和——即,sleep 1 將導致其增加 0,但一圈忙迴圈將導致其增加 1。

華夏公益教科書