Last active
October 19, 2018 16:39
-
-
Save eugeneius/f2ccf1694d8759df7884 to your computer and use it in GitHub Desktop.
Benchmark for schema cache dump changes: https://github.com/rails/rails/pull/17632
This file contains hidden or 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
| #!/usr/bin/env ruby | |
| require_relative 'setup' | |
| require 'benchmark/ips' | |
| class ModelOne < ActiveRecord::Base; end | |
| class ModelTwo < ActiveRecord::Base; end | |
| class ModelThree < ActiveRecord::Base; end | |
| Benchmark.ips do |x| | |
| x.warmup = 5 | |
| x.time = 10 | |
| x.report do | |
| ModelOne.reset_column_information | |
| ModelTwo.reset_column_information | |
| ModelThree.reset_column_information | |
| ActiveRecord::Base.connection_pool.disconnect! | |
| threads = [] | |
| 5.times do | |
| threads << Thread.new do | |
| ModelOne.first | |
| ModelTwo.first | |
| ModelThree.first | |
| ActiveRecord::Base.connection.close | |
| end | |
| end | |
| threads.each(&:join) | |
| end | |
| end |
This file contains hidden or 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
| development: | |
| adapter: mysql2 | |
| encoding: utf8 | |
| pool: 5 | |
| username: root | |
| password: | |
| host: localhost | |
| database: schema_cache_dump_connection_pool_benchmark |
This file contains hidden or 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
| source 'https://rubygems.org' | |
| gem 'rails', github: 'rails/rails' | |
| gem 'mysql2' | |
| gem 'benchmark-ips' |
This file contains hidden or 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
| GIT | |
| remote: git://github.com/rails/rails.git | |
| revision: 390449ab8c55dacc08517bc270c6203bb1f50e02 | |
| specs: | |
| actionmailer (5.0.0.alpha) | |
| actionpack (= 5.0.0.alpha) | |
| actionview (= 5.0.0.alpha) | |
| activejob (= 5.0.0.alpha) | |
| mail (~> 2.5, >= 2.5.4) | |
| rails-dom-testing (~> 1.0, >= 1.0.5) | |
| actionpack (5.0.0.alpha) | |
| actionview (= 5.0.0.alpha) | |
| activesupport (= 5.0.0.alpha) | |
| rack (~> 1.6.0.beta2) | |
| rack-test (~> 0.6.2) | |
| rails-dom-testing (~> 1.0, >= 1.0.5) | |
| rails-html-sanitizer (~> 1.0, >= 1.0.1) | |
| actionview (5.0.0.alpha) | |
| activesupport (= 5.0.0.alpha) | |
| builder (~> 3.1) | |
| erubis (~> 2.7.0) | |
| rails-dom-testing (~> 1.0, >= 1.0.5) | |
| rails-html-sanitizer (~> 1.0, >= 1.0.1) | |
| activejob (5.0.0.alpha) | |
| activesupport (= 5.0.0.alpha) | |
| globalid (>= 0.3.0) | |
| activemodel (5.0.0.alpha) | |
| activesupport (= 5.0.0.alpha) | |
| builder (~> 3.1) | |
| activerecord (5.0.0.alpha) | |
| activemodel (= 5.0.0.alpha) | |
| activesupport (= 5.0.0.alpha) | |
| arel (~> 6.0) | |
| activesupport (5.0.0.alpha) | |
| i18n (>= 0.7.0.beta1, < 0.8) | |
| json (~> 1.7, >= 1.7.7) | |
| minitest (~> 5.1) | |
| thread_safe (~> 0.1) | |
| tzinfo (~> 1.1) | |
| rails (5.0.0.alpha) | |
| actionmailer (= 5.0.0.alpha) | |
| actionpack (= 5.0.0.alpha) | |
| actionview (= 5.0.0.alpha) | |
| activejob (= 5.0.0.alpha) | |
| activemodel (= 5.0.0.alpha) | |
| activerecord (= 5.0.0.alpha) | |
| activesupport (= 5.0.0.alpha) | |
| bundler (>= 1.3.0, < 2.0) | |
| railties (= 5.0.0.alpha) | |
| sprockets-rails | |
| railties (5.0.0.alpha) | |
| actionpack (= 5.0.0.alpha) | |
| activesupport (= 5.0.0.alpha) | |
| rake (>= 0.8.7) | |
| thor (>= 0.18.1, < 2.0) | |
| GEM | |
| remote: https://rubygems.org/ | |
| specs: | |
| arel (6.0.0) | |
| benchmark-ips (2.1.0) | |
| builder (3.2.2) | |
| erubis (2.7.0) | |
| globalid (0.3.0) | |
| activesupport (>= 4.1.0) | |
| hike (1.2.3) | |
| i18n (0.7.0.beta1) | |
| json (1.8.1) | |
| loofah (2.0.1) | |
| nokogiri (>= 1.5.9) | |
| mail (2.6.3) | |
| mime-types (>= 1.16, < 3) | |
| mime-types (2.4.3) | |
| mini_portile (0.6.1) | |
| minitest (5.4.3) | |
| multi_json (1.10.1) | |
| mysql2 (0.3.17) | |
| nokogiri (1.6.5) | |
| mini_portile (~> 0.6.0) | |
| rack (1.6.0.beta2) | |
| rack-test (0.6.2) | |
| rack (>= 1.0) | |
| rails-deprecated_sanitizer (1.0.3) | |
| activesupport (>= 4.2.0.alpha) | |
| rails-dom-testing (1.0.5) | |
| activesupport (>= 4.2.0.beta, < 5.0) | |
| nokogiri (~> 1.6.0) | |
| rails-deprecated_sanitizer (>= 1.0.1) | |
| rails-html-sanitizer (1.0.1) | |
| loofah (~> 2.0) | |
| rake (10.4.0) | |
| sprockets (2.12.3) | |
| hike (~> 1.2) | |
| multi_json (~> 1.0) | |
| rack (~> 1.0) | |
| tilt (~> 1.1, != 1.3.0) | |
| sprockets-rails (2.2.1) | |
| actionpack (>= 3.0) | |
| activesupport (>= 3.0) | |
| sprockets (>= 2.8, < 4.0) | |
| thor (0.19.1) | |
| thread_safe (0.3.4) | |
| tilt (1.4.1) | |
| tzinfo (1.2.2) | |
| thread_safe (~> 0.1) | |
| PLATFORMS | |
| ruby | |
| DEPENDENCIES | |
| benchmark-ips | |
| mysql2 | |
| rails! |
This file contains hidden or 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
| source 'https://rubygems.org' | |
| gem 'rails', github: 'eugeneius/rails', branch: 'schema_cache_dump_connection_pool' | |
| gem 'mysql2' | |
| gem 'benchmark-ips' |
This file contains hidden or 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
| GIT | |
| remote: git://github.com/eugeneius/rails.git | |
| revision: 7ddc51703e289ab377c8dbb5ff517fa4318126d3 | |
| branch: schema_cache_dump_connection_pool | |
| specs: | |
| actionmailer (5.0.0.alpha) | |
| actionpack (= 5.0.0.alpha) | |
| actionview (= 5.0.0.alpha) | |
| activejob (= 5.0.0.alpha) | |
| mail (~> 2.5, >= 2.5.4) | |
| rails-dom-testing (~> 1.0, >= 1.0.5) | |
| actionpack (5.0.0.alpha) | |
| actionview (= 5.0.0.alpha) | |
| activesupport (= 5.0.0.alpha) | |
| rack (~> 1.6.0.beta2) | |
| rack-test (~> 0.6.2) | |
| rails-dom-testing (~> 1.0, >= 1.0.5) | |
| rails-html-sanitizer (~> 1.0, >= 1.0.1) | |
| actionview (5.0.0.alpha) | |
| activesupport (= 5.0.0.alpha) | |
| builder (~> 3.1) | |
| erubis (~> 2.7.0) | |
| rails-dom-testing (~> 1.0, >= 1.0.5) | |
| rails-html-sanitizer (~> 1.0, >= 1.0.1) | |
| activejob (5.0.0.alpha) | |
| activesupport (= 5.0.0.alpha) | |
| globalid (>= 0.3.0) | |
| activemodel (5.0.0.alpha) | |
| activesupport (= 5.0.0.alpha) | |
| builder (~> 3.1) | |
| activerecord (5.0.0.alpha) | |
| activemodel (= 5.0.0.alpha) | |
| activesupport (= 5.0.0.alpha) | |
| arel (~> 6.0) | |
| activesupport (5.0.0.alpha) | |
| i18n (>= 0.7.0.beta1, < 0.8) | |
| json (~> 1.7, >= 1.7.7) | |
| minitest (~> 5.1) | |
| thread_safe (~> 0.1) | |
| tzinfo (~> 1.1) | |
| rails (5.0.0.alpha) | |
| actionmailer (= 5.0.0.alpha) | |
| actionpack (= 5.0.0.alpha) | |
| actionview (= 5.0.0.alpha) | |
| activejob (= 5.0.0.alpha) | |
| activemodel (= 5.0.0.alpha) | |
| activerecord (= 5.0.0.alpha) | |
| activesupport (= 5.0.0.alpha) | |
| bundler (>= 1.3.0, < 2.0) | |
| railties (= 5.0.0.alpha) | |
| sprockets-rails | |
| railties (5.0.0.alpha) | |
| actionpack (= 5.0.0.alpha) | |
| activesupport (= 5.0.0.alpha) | |
| rake (>= 0.8.7) | |
| thor (>= 0.18.1, < 2.0) | |
| GEM | |
| remote: https://rubygems.org/ | |
| specs: | |
| arel (6.0.0) | |
| benchmark-ips (2.1.0) | |
| builder (3.2.2) | |
| erubis (2.7.0) | |
| globalid (0.3.0) | |
| activesupport (>= 4.1.0) | |
| hike (1.2.3) | |
| i18n (0.7.0.beta1) | |
| json (1.8.1) | |
| loofah (2.0.1) | |
| nokogiri (>= 1.5.9) | |
| mail (2.6.3) | |
| mime-types (>= 1.16, < 3) | |
| mime-types (2.4.3) | |
| mini_portile (0.6.1) | |
| minitest (5.4.3) | |
| multi_json (1.10.1) | |
| mysql2 (0.3.17) | |
| nokogiri (1.6.5) | |
| mini_portile (~> 0.6.0) | |
| rack (1.6.0.beta2) | |
| rack-test (0.6.2) | |
| rack (>= 1.0) | |
| rails-deprecated_sanitizer (1.0.3) | |
| activesupport (>= 4.2.0.alpha) | |
| rails-dom-testing (1.0.5) | |
| activesupport (>= 4.2.0.beta, < 5.0) | |
| nokogiri (~> 1.6.0) | |
| rails-deprecated_sanitizer (>= 1.0.1) | |
| rails-html-sanitizer (1.0.1) | |
| loofah (~> 2.0) | |
| rake (10.4.0) | |
| sprockets (2.12.3) | |
| hike (~> 1.2) | |
| multi_json (~> 1.0) | |
| rack (~> 1.0) | |
| tilt (~> 1.1, != 1.3.0) | |
| sprockets-rails (2.2.1) | |
| actionpack (>= 3.0) | |
| activesupport (>= 3.0) | |
| sprockets (>= 2.8, < 4.0) | |
| thor (0.19.1) | |
| thread_safe (0.3.4) | |
| tilt (1.4.1) | |
| tzinfo (1.2.2) | |
| thread_safe (~> 0.1) | |
| PLATFORMS | |
| ruby | |
| DEPENDENCIES | |
| benchmark-ips | |
| mysql2 | |
| rails! |
This file contains hidden or 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_relative 'setup' | |
| Rails.application.load_tasks |
This file contains hidden or 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 'bundler/setup' | |
| require 'active_record/railtie' | |
| module SchemaCacheDumpConnectionPoolBenchmark | |
| class Application < Rails::Application | |
| config.eager_load = false | |
| config.paths['config/database'].concat(Dir['database.yml']) | |
| end | |
| end | |
| Rails.application.initialize! | |
| ActiveRecord::Base.connection.instance_eval do | |
| create_table :model_ones, force: true do |t| | |
| t.text :text | |
| t.timestamps null: false | |
| end | |
| create_table :model_twos, force: true do |t| | |
| t.text :text | |
| t.timestamps null: false | |
| end | |
| create_table :model_threes, force: true do |t| | |
| t.text :text | |
| t.timestamps null: false | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment