Module: Vedeu::Logging::Debug
Overview
Provides a stack trace of a running client application upon exit in a file for further analysis.
Class Method Summary collapse
-
.profile(filename = 'profile.html') ⇒ void
:nocov: Helps to profile a running application by providing a stack trace of its execution upon exiting.
Class Method Details
.profile(filename = 'profile.html') ⇒ void
This method returns an undefined value.
:nocov: Helps to profile a running application by providing a stack trace of its execution upon exiting.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/vedeu/logging/debug.rb', line 25 def self.profile(filename = 'profile.html') return nil unless block_given? require 'ruby-prof' # RubyProf.measure_mode = RubyProf::WALL_TIME # RubyProf.measure_mode = RubyProf::PROCESS_TIME RubyProf.measure_mode = RubyProf::CPU_TIME # RubyProf.measure_mode = RubyProf::ALLOCATIONS # RubyProf.measure_mode = RubyProf::MEMORY # RubyProf.measure_mode = RubyProf::GC_TIME # RubyProf.measure_mode = RubyProf::GC_RUNS RubyProf.start work = yield result = RubyProf.stop result.eliminate_methods!([ /^Array/, /^Hash/, /^String/, /^Fixnum/, ]) File.open('/tmp/' + filename, 'w') do |file| # - Creates a HTML visualization of the Ruby stack RubyProf::CallStackPrinter.new(result).print(file) # Used with QTCacheGrind to analyse performance. # RubyProf::CallTreePrinter.new(result).print(file) # Creates a flat report in text format # RubyProf::FlatPrinter # - same as above but more verbose # RubyProf::FlatPrinterWithLineNumbers # - Creates a call graph report in text format # RubyProf::GraphPrinter # - Creates a call graph report in HTML (separate files per # thread) # RubyProf::GraphHtmlPrinter # - Creates a call graph report in GraphViz's DOT format # which can be converted to an image # RubyProf::DotPrinter # - Creates a call tree report compatible with KCachegrind. # RubyProf::CallTreePrinter # - Uses the other printers to create several reports in one # profiling run # RubyProf::MultiPrinter end work end |