Skip to content

Instantly share code, notes, and snippets.

@stratigos
Last active January 9, 2017 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stratigos/d97c7afbab2eef59b9574181e1501c72 to your computer and use it in GitHub Desktop.
Save stratigos/d97c7afbab2eef59b9574181e1501c72 to your computer and use it in GitHub Desktop.
Example Tool for Profiling Memory Use in Ruby Scripts and Applications
#################################
# GEMFILE: gem 'get_process_mem'
#################################
require 'get_process_mem'
def profile_mem(description=nil)
mb = GetProcessMem.new.mb
puts "\n\n---- #{ description } - MEMORY USAGE(MB): #{ mb.round } ----\n\n"
end
# Before some block/procedure to profile:
profile_mem 'BEFORE PROCEDURE'
# Procedure executes...
# After some block/procedure to profile:
profile_mem 'AFTER PROCEDURE'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment