Sha256: 0be0cc36633dea430f0a49b2e0efe1f84a415b5e19add538120fdd78874340e7
Contents?: true
Size: 1.04 KB
Versions: 6
Compression:
Stored size: 1.04 KB
Contents
module Spider module Profiling def self.start raise "Profiling already started" if @profiling_started unless Spider.request_mutex Spider.mutex_requests! Spider.request_mutex.lock end require 'ruby-prof' Spider.logger.debug("Starting profiling") @profiling_started = true RubyProf.start end def self.stop Spider.request_mutex.unlock Spider.request_mutex = nil result = RubyProf.stop @profiling_started = false printer = ::RubyProf::GraphHtmlPrinter.new(result) file_name = Spider.paths[:tmp]+"/prof_#{DateTime.now.to_s}.html" File.open(file_name, 'w') do |f| printer.print(f, :min_percent => 0) end Spider.logger.info("Written profiling info in #{file_name}") end def self.started? @profiling_started end end end
Version data entries
6 entries across 6 versions & 1 rubygems