Class: Tracer

Inherits:
Object
  • Object
show all
Includes:
TimeHelpers
Defined in:
lib/shoes/profiler.rb

Overview

if

Constant Summary collapse

EVENTS =
[:call, :return, :c_call, :c_return]

Instance Method Summary collapse

Methods included from TimeHelpers

#cpu_time, #wall_time

Constructor Details

#initialize(reporter, c_calls) ⇒ Tracer

Returns a new instance of Tracer



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/shoes/profiler.rb', line 53

def initialize(reporter, c_calls)
    @reporter = reporter
    events = c_calls ? EVENTS : EVENTS - [:c_call, :c_return]
    
    @tracepoints = events.map do |event|
        TracePoint.new(event) do |trace|
            reporter.record(event, trace.method_id, cpu_time)
        end
    end
    
end

Instance Method Details

#disableObject



66
# File 'lib/shoes/profiler.rb', line 66

def disable; @tracepoints.each(&:disable) end

#enableObject



65
# File 'lib/shoes/profiler.rb', line 65

def enable; @tracepoints.each(&:enable) end

#resultObject



67
# File 'lib/shoes/profiler.rb', line 67

def result; @reporter.result end