Sha256: 61ec9350829fd3ebb79e06fba12f3e6e8c2076150bf64d2e917c3b6b783a3ccd

Contents?: true

Size: 608 Bytes

Versions: 5

Compression:

Stored size: 608 Bytes

Contents

module Vedeu

  # Helps to debug a running application by providing a stack trace of its
  # execution upon exiting.
  #
  # @param filename [String]
  # @param block [Proc]
  def self.debug(filename = 'profile.html', &block)
    require 'ruby-prof'

    RubyProf.start

    yield

    result = RubyProf.stop
    result.eliminate_methods!([/^Array/, /^Hash/])

    File.open('/tmp/' + filename, 'w') do |file|
      RubyProf::CallStackPrinter.new(result).print(file)

      # Used with QTCacheGrind to analyse performance.
      # RubyProf::CallTreePrinter.new(result).print(file)
    end
  end

end # Vedeu

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vedeu-0.4.7 lib/vedeu/debug.rb
vedeu-0.4.6 lib/vedeu/debug.rb
vedeu-0.4.5 lib/vedeu/debug.rb
vedeu-0.4.4 lib/vedeu/debug.rb
vedeu-0.4.3 lib/vedeu/debug.rb