Skip to content

Instantly share code, notes, and snippets.

@pgeraghty
Created March 15, 2015 10:13
Show Gist options
  • Save pgeraghty/6b2f4fc22f71890aaa3b to your computer and use it in GitHub Desktop.
Save pgeraghty/6b2f4fc22f71890aaa3b to your computer and use it in GitHub Desktop.
Memory profiling for requires - Ruby
if ENV['MEMORY_PROFILING']
require 'benchmark'
def require(file)
puts `pmap #{Process.pid} | grep 'total'`
puts Benchmark.measure('') { super }.format("%t require #{file}")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment