Skip to content

Instantly share code, notes, and snippets.

@jrafanie
Last active October 14, 2015 19:26
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 jrafanie/636b5e14790b338f1522 to your computer and use it in GitHub Desktop.
Save jrafanie/636b5e14790b338f1522 to your computer and use it in GitHub Desktop.
Track allocations in ems refresh
# How to run:
# bundle exec evm:db:reset > /dev/null && bundle exec rails r setup_ems.rb && bundle exec rails r run_refresh.rb
def miq_trace(description = "")
require 'allocation_tracer'
ObjectSpace::AllocationTracer.setup(%i{type class})
result = ObjectSpace::AllocationTracer.trace do
yield
nil
end
puts "All #{description.to_s + ' '}allocations"
result.sort_by { |_, v| -v[0] }[0..100].each {|k, v|
puts "#{v[0]}\t#{k[0]}:#{k[1]}\t#{k[2]}\t#{k[3]}\t#{k[4]}"
}
end
EmsRefresh.init_console(false)
miq_trace do
e = ExtManagementSystem.first
EmsRefresh.refresh(e)
end
EvmDatabase.seed_primordial
ExtManagementSystem.destroy_all
e = ManageIQ::Providers::InfraManager.create(:name => "small", :hostname => "10.12.20.65", :type => "ManageIQ::Providers::Vmware::InfraManager", :ipaddress => "10.12.20.65", :zone => Zone.default_zone)
e.update_authentication(:default => {:userid => "ASKME", :password => "ASKME"})
puts e.verify_credentials
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment