Sha256: e0b169a071b671f023ca8faf9cb79a14c1d54ff596de04687ee56060e3e80dfd

Contents?: true

Size: 632 Bytes

Versions: 2

Compression:

Stored size: 632 Bytes

Contents

module Vedeu

  # :nocov:
  # 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
  # :nocov:

end # Vedeu

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vedeu-0.4.9 lib/vedeu/debug.rb
vedeu-0.4.8 lib/vedeu/debug.rb