Sha256: 271ec9ea09c11251eaf7d280f15ba8fdde60aa8b90d9d592887d1ce40dfabc6a

Contents?: true

Size: 672 Bytes

Versions: 3

Compression:

Stored size: 672 Bytes

Contents

require 'rblineprof'

module Pilfer
  class Profiler
    attr_reader :reporter

    def initialize(reporter)
      @reporter = reporter
    end

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

    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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pilfer-1.0.2 lib/pilfer/profiler.rb
pilfer-1.0.1 lib/pilfer/profiler.rb
pilfer-1.0.0 lib/pilfer/profiler.rb