Sha256: 0139f09858e311ddb89c0243a1db26a63a9c69841567263b4bccdff62cf62127

Contents?: true

Size: 628 Bytes

Versions: 4

Compression:

Stored size: 628 Bytes

Contents

require 'pry'
require 'pry-nav'
require 'ruby-prof'

module Troo
  # @param  [String]
  # @param  []
  # @return []
  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

  def self.trace
    trace = TracePoint.new(:call) do |tp|
      if tp.defined_class.to_s.match(/Troo/)
        Troo.logger.debug [tp.defined_class.to_s, tp.method_id.to_s].join(' ')
      end
    end
    trace.enable
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
troo-0.0.15 lib/troo/debug.rb
troo-0.0.14 lib/troo/debug.rb
troo-0.0.13 lib/troo/debug.rb
troo-0.0.12 lib/troo/debug.rb