Created
October 15, 2015 16:21
-
-
Save tenderlove/3ee912a95122debe9f1a to your computer and use it in GitHub Desktop.
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_record' | |
class Topic < ActiveRecord::Base | |
end | |
20.times do |i| | |
Process.waitpid fork { | |
ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:' | |
ActiveRecord::Base.connection.instance_eval do | |
create_table(:topics) do |t| | |
t.string :title, limit: 250 | |
t.string :author_name | |
t.string :author_email_address | |
t.string :parent_title | |
t.string :type | |
t.string :group | |
i.times do |j| | |
t.integer :"aaa#{j}" | |
end | |
t.timestamps null: true | |
end | |
end | |
ObjectSpace::AllocationTracer.setup(%i{type}) | |
Topic.create title: "aaron" # heat cache | |
result = ObjectSpace::AllocationTracer.trace do | |
10.times do |i| | |
Topic.create title: "aaron #{i}" | |
end | |
end | |
puts "#{Topic.columns.length},#{(result.find { |k,v| k.first == :T_STRING }.last.first / 10)}" | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment