Method: Vuf::Profiler#run

Defined in:
lib/vuf/profiler.rb

#run(delay = 10) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/vuf/profiler.rb', line 89

def run(delay=10)
  return if @stat_thread
  
  @stat_thread = Thread.new do
    enable ; GC::Profiler.enable ; @running = true
    while @running
      start('total') ; sleep(delay) ; stop('total')
      gc_result = [] ; GC::Profiler.result.each_line{|l| gc_result << l}
      Logger.info "Profiling Result : \n  - #{result}\n#{gc_result.shift}#{gc_result.first}#{gc_result.last}"
    end
    GC::Profiler.disable ; disable
  end
  # Ensure that finaliz was call at exit

  Kernel.at_exit { finalize }
end