class SpeedGun::Profiler::LineProfiler

Public Class Methods

regexp() click to toggle source
# File lib/speed_gun/profiler/line_profiler.rb, line 7
def self.regexp
  if SpeedGun.config.lineprof_paths.empty?
    %r{.}
  else
    Regexp.union(*SpeedGun.config.lineprof_paths)
  end
end

Public Instance Methods

profile(*_args) { || ... } click to toggle source
# File lib/speed_gun/profiler/line_profiler.rb, line 15
def profile(*_args)
  return yield if self.class.ignore?

  result = nil
  lineprofiled = lineprof(self.class.regexp) do
    result = yield
  end
  store(lineprofiled) if SpeedGun.current_report
  result
end
store(lineprofiled) click to toggle source
# File lib/speed_gun/profiler/line_profiler.rb, line 26
def store(lineprofiled)
  lineprofiled.each_pair do |file, linesamples|
    source = SpeedGun::Source.new(file, linesamples)
    SpeedGun.current_report.source(source) unless source.lines.empty?
  end
end