Class: Tracy

Inherits:
Object
  • Object
show all
Defined in:
lib/tracy.rb

Instance Method Summary collapse

Constructor Details

#initializeTracy

Returns a new instance of Tracy.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/tracy.rb', line 6

def initialize
  @callers = Hash.new { |hash, key| hash[key] = {} }
  @trace = TracePoint.new(:call, :line) do |tp|
    case tp.event
    when :call
      @callers[data_array(tp)][@current_location] = 1
    when :line
      @current_location = data_array(tp)
    end
  end
end

Instance Method Details

#doneObject



22
23
24
25
# File 'lib/tracy.rb', line 22

def done
  @trace.disable
  File.write("callsite-info.yml", YAML.dump(@callers))
end

#startObject



18
19
20
# File 'lib/tracy.rb', line 18

def start
  @trace.enable
end