discourse/script/test_mem.rb

42 lines
832 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2013-11-27 19:40:10 -06:00
start = Time.now
require "objspace"
2013-11-27 19:40:10 -06:00
require File.expand_path("../../config/environment", __FILE__)
# preload stuff
I18n.t(:posts)
# load up all models and schema
(ActiveRecord::Base.connection.tables - %w[schema_migrations]).each do |table|
begin
table.classify.constantize.first
rescue StandardError
nil
end
2013-11-27 19:40:10 -06:00
end
# router warm up
begin
Rails.application.routes.recognize_path("abc")
rescue StandardError
nil
end
2013-11-27 19:40:10 -06:00
puts "Ruby version #{RUBY_VERSION} p#{RUBY_PATCHLEVEL}"
puts "Bootup time: #{Time.now - start} secs"
GC.start
puts "RSS: #{`ps -o rss -p #{$$}`.chomp.split("\n").last.to_i} KB"
s =
ObjectSpace
.each_object(String)
.map do |o|
ObjectSpace.memsize_of(o) + 40 # rvalue size on x64
end
2013-11-27 19:40:10 -06:00
puts "Total strings: #{s.count} space used: #{s.sum} bytes"