Sha256: 2e14ba8c3a1ace42496c5969cb122606486d1493477cd5ae8f2231a5de2361e4

Contents?: true

Size: 490 Bytes

Versions: 3

Compression:

Stored size: 490 Bytes

Contents

require 'ruby-prof'

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)
    RubyProf.start

    yield

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

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

end # Vedeu

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vedeu-0.4.1 lib/vedeu/debug.rb
vedeu-0.4.0 lib/vedeu/debug.rb
vedeu-0.3.5 lib/vedeu/debug.rb