class RSpecProf

Attributes

printer_class[RW]

Public Class Methods

profile(filename) { || ... } click to toggle source
# File lib/rspec-prof.rb, line 14
def profile filename
  profiler = new.start
  yield
ensure
  profiler.save_to filename
end

Public Instance Methods

profiling?() click to toggle source
# File lib/rspec-prof.rb, line 35
def profiling?
  @profiling
end
result() click to toggle source
# File lib/rspec-prof.rb, line 39
def result
  @result
end
save_to(filename) click to toggle source
# File lib/rspec-prof.rb, line 43
def save_to filename
  stop
  FileUtils.mkdir_p File.dirname(filename)
  File.open(filename, "w") do |f|
    printer = RSpecProf.printer_class.new(result)
    printer.print(f, :min_percent => 1)
  end
end
start() click to toggle source
# File lib/rspec-prof.rb, line 22
def start
  return if @profiling
  @profiling = true
  RubyProf.start
  self
end
stop() click to toggle source
# File lib/rspec-prof.rb, line 29
def stop
  return unless @profiling
  @profiling = false
  @result = RubyProf.stop
end