Skip to content

Instantly share code, notes, and snippets.

@phiggins
Created August 7, 2010 08:33
Show Gist options
  • Save phiggins/512596 to your computer and use it in GitHub Desktop.
Save phiggins/512596 to your computer and use it in GitHub Desktop.
class Inspect
def self.profile
require 'ruby-prof'
RubyProf.start
result = yield
prof_result = RubyProf.stop
printer = RubyProf::FlatPrinter.new(prof_result)
printer.print(STDOUT)
result
end
end
# Usage
#
# return_value_from_method = Inspect.profile { foo.some_suspect_method }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment