Class: RubyProf::Walker

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-prof/walker.rb

Direct Known Subclasses

FlameGraphJsonPrinter::FlameDataWalker

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(roots, options = {}) ⇒ Walker

Returns a new instance of Walker.



6
7
8
9
10
11
12
13
# File 'lib/ruby-prof/walker.rb', line 6

def initialize(roots, options={})
  @roots = roots
  @options = options

  @all_time = @roots.map(&:total_time).inject(0.0, &:+)
  @min_percent = options[:min_percent] || 2
  @min_self_percent = options[:min_self_percent] || 0.001
end

Instance Attribute Details

#min_fractionObject (readonly)

Returns the value of attribute min_fraction.



4
5
6
# File 'lib/ruby-prof/walker.rb', line 4

def min_fraction
  @min_fraction
end

#rootsObject (readonly)

Returns the value of attribute roots.



3
4
5
# File 'lib/ruby-prof/walker.rb', line 3

def roots
  @roots
end

Instance Method Details

#enter_frame(type, obj, name, called, elf_value, total_value) ⇒ Object

Raises:

  • (NotImplementedError)


21
22
23
# File 'lib/ruby-prof/walker.rb', line 21

def enter_frame(type, obj, name, called, elf_value, total_value)
  raise NotImplementedError
end

#leave_frame(type, obj) ⇒ Object

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/ruby-prof/walker.rb', line 25

def leave_frame(type, obj)
  raise NotImplementedError
end

#runObject



15
16
17
18
19
# File 'lib/ruby-prof/walker.rb', line 15

def run
  around_frame(@roots, :all, "all", 1, 0.0, @all_time) do
    @roots.each { |r| visit(r) }
  end
end