Created
June 27, 2023 00:07
-
-
Save aks/a4cc7eb217c7798f1132f5299e175a88 to your computer and use it in GitHub Desktop.
ActiveRecord memory size usage (minimal and all)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'get_process_mem' | |
def mem_usage(label) | |
Process.fork do | |
m_before = mem_size | |
yield | |
m_after = mem_size | |
$stderr.printf "%30s: delta: %+3d MB total: %5d MB\n", label, (m_after - m_before), m_after | |
end | |
end | |
def mem_size(digits=0) | |
@mem ||= GetProcessMem.new | |
@mem.mb.round(0) | |
end | |
mem_usage('Require active_support') { require 'active_support' } | |
mem_usage('Require active_support/all') { require 'active_support/all' } | |
$stderr.flush | |
exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Require active_support: delta: +12 MB total: 14 MB | |
Require active_support/all: delta: +24 MB total: 25 MB |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment