Skip to content

Instantly share code, notes, and snippets.

@fujimura
Created July 4, 2011 01:02
Show Gist options
  • Save fujimura/1062779 to your computer and use it in GitHub Desktop.
Save fujimura/1062779 to your computer and use it in GitHub Desktop.
def instrument
memory_before = `ps -o rss= #{$$}`
RubyProf.start
yield
result = RubyProf.stop
memory_after = `ps -o rss= #{$$}`
p "Memory before: #{memory_before.chomp}"
p "Memory after: #{memory_after.chomp}"
printer = RubyProf::FlatPrinter.new(result)
printer.print(STDOUT, 0)
nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment