2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-11-28 09:40:10 +08:00
|
|
|
start = Time.now
|
|
|
|
require "objspace"
|
|
|
|
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|
|
2023-01-07 19:53:14 +08:00
|
|
|
begin
|
2013-11-28 09:40:10 +08:00
|
|
|
table.classify.constantize.first
|
|
|
|
rescue StandardError
|
|
|
|
nil
|
2023-01-07 19:53:14 +08:00
|
|
|
end
|
2013-11-28 09:40:10 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
# router warm up
|
2023-01-07 19:53:14 +08:00
|
|
|
begin
|
2013-11-28 09:40:10 +08:00
|
|
|
Rails.application.routes.recognize_path("abc")
|
|
|
|
rescue StandardError
|
|
|
|
nil
|
2023-01-07 19:53:14 +08:00
|
|
|
end
|
2013-11-28 09:40:10 +08: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
|
|
|
|
|
|
|
|
puts "Total strings: #{s.count} space used: #{s.sum} bytes"
|