Class: Profiler

Inherits:
Object show all
Defined in:
lib/watirmark/profile.rb

Class Method Summary collapse

Class Method Details

.profile(options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/watirmark/profile.rb', line 4

def self.profile(options={})
  RubyProf.start
  beginning = Time.now
  puts '-----------------------'
  puts options[:name]
  puts '-----------------------'
  yield
  result = RubyProf.stop
  result.eliminate_methods!([/IO/, /Net::/, /Global/])
  printer = RubyProf::FlatPrinter.new(result)
  printer.print(STDOUT, :min_percent=> (options[:min_percent] || 1))
  puts "----> Time elapsed #{Time.now - beginning} seconds"
end