Class: Pilfer::Profiler

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reporter) ⇒ Profiler

Returns a new instance of Profiler.



7
8
9
# File 'lib/pilfer/profiler.rb', line 7

def initialize(reporter)
  @reporter = reporter
end

Instance Attribute Details

#reporterObject (readonly)

Returns the value of attribute reporter.



5
6
7
# File 'lib/pilfer/profiler.rb', line 5

def reporter
  @reporter
end

Instance Method Details

#profile(*args, &app) ⇒ Object



11
12
13
# File 'lib/pilfer/profiler.rb', line 11

def profile(*args, &app)
  profile_files_matching(/./, *args, &app)
end

#profile_files_matching(matcher, description = nil, reporter_options = {}, profiler = method(:lineprof), start = Time.now, &app) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pilfer/profiler.rb', line 15

def profile_files_matching(matcher, description = nil,
                           reporter_options = {},
                           profiler = method(:lineprof),
                           start = Time.now, &app)
  app_response = nil
  profile = profiler.call(matcher) do
    app_response = app.call
  end
  reporter.write profile, start, description, reporter_options
  app_response
end