gitlab-derailed_benchmarks 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/check_changelog.yml +10 -0
  3. data/.gitignore +8 -0
  4. data/.gitlab-ci.yml +56 -0
  5. data/.travis.yml +18 -0
  6. data/Appraisals +26 -0
  7. data/CHANGELOG.md +105 -0
  8. data/Gemfile +9 -0
  9. data/README.md +692 -0
  10. data/Rakefile +29 -0
  11. data/bin/derailed +93 -0
  12. data/derailed_benchmarks.gemspec +39 -0
  13. data/gemfiles/.bundle/config +2 -0
  14. data/gemfiles/rails_5_1.gemfile +15 -0
  15. data/gemfiles/rails_5_2.gemfile +15 -0
  16. data/gemfiles/rails_6_0.gemfile +15 -0
  17. data/gemfiles/rails_git.gemfile +19 -0
  18. data/lib/derailed_benchmarks.rb +51 -0
  19. data/lib/derailed_benchmarks/auth_helper.rb +34 -0
  20. data/lib/derailed_benchmarks/auth_helpers/devise.rb +41 -0
  21. data/lib/derailed_benchmarks/core_ext/kernel_require.rb +88 -0
  22. data/lib/derailed_benchmarks/load_tasks.rb +145 -0
  23. data/lib/derailed_benchmarks/require_tree.rb +65 -0
  24. data/lib/derailed_benchmarks/stats_from_dir.rb +128 -0
  25. data/lib/derailed_benchmarks/stats_in_file.rb +60 -0
  26. data/lib/derailed_benchmarks/tasks.rb +292 -0
  27. data/lib/derailed_benchmarks/version.rb +5 -0
  28. data/test/derailed_benchmarks/core_ext/kernel_require_test.rb +33 -0
  29. data/test/derailed_benchmarks/require_tree_test.rb +95 -0
  30. data/test/derailed_benchmarks/stats_from_dir_test.rb +125 -0
  31. data/test/derailed_test.rb +14 -0
  32. data/test/fixtures/require/child_one.rb +4 -0
  33. data/test/fixtures/require/child_two.rb +9 -0
  34. data/test/fixtures/require/parent_one.rb +8 -0
  35. data/test/fixtures/require/raise_child.rb +6 -0
  36. data/test/fixtures/require/relative_child.rb +4 -0
  37. data/test/fixtures/require/relative_child_two.rb +4 -0
  38. data/test/fixtures/stats/significant/loser.bench.txt +100 -0
  39. data/test/fixtures/stats/significant/winner.bench.txt +100 -0
  40. data/test/integration/tasks_test.rb +132 -0
  41. data/test/rails_app/Rakefile +9 -0
  42. data/test/rails_app/app/assets/config/manifest.js +0 -0
  43. data/test/rails_app/app/assets/javascripts/authenticated.js +2 -0
  44. data/test/rails_app/app/assets/stylesheets/authenticated.css +4 -0
  45. data/test/rails_app/app/controllers/application_controller.rb +17 -0
  46. data/test/rails_app/app/controllers/authenticated_controller.rb +8 -0
  47. data/test/rails_app/app/controllers/pages_controller.rb +14 -0
  48. data/test/rails_app/app/helpers/application_helper.rb +4 -0
  49. data/test/rails_app/app/helpers/authenticated_helper.rb +4 -0
  50. data/test/rails_app/app/models/user.rb +13 -0
  51. data/test/rails_app/app/views/authenticated/index.html.erb +1 -0
  52. data/test/rails_app/app/views/layouts/application.html.erb +14 -0
  53. data/test/rails_app/app/views/pages/index.html.erb +1 -0
  54. data/test/rails_app/config.ru +6 -0
  55. data/test/rails_app/config/application.rb +52 -0
  56. data/test/rails_app/config/boot.rb +12 -0
  57. data/test/rails_app/config/database.yml +22 -0
  58. data/test/rails_app/config/environment.rb +11 -0
  59. data/test/rails_app/config/environments/development.rb +27 -0
  60. data/test/rails_app/config/environments/production.rb +51 -0
  61. data/test/rails_app/config/environments/test.rb +37 -0
  62. data/test/rails_app/config/initializers/backtrace_silencers.rb +9 -0
  63. data/test/rails_app/config/initializers/devise.rb +258 -0
  64. data/test/rails_app/config/initializers/inflections.rb +12 -0
  65. data/test/rails_app/config/initializers/mime_types.rb +7 -0
  66. data/test/rails_app/config/initializers/secret_token.rb +13 -0
  67. data/test/rails_app/config/initializers/session_store.rb +10 -0
  68. data/test/rails_app/config/locales/devise.en.yml +59 -0
  69. data/test/rails_app/config/locales/en.yml +9 -0
  70. data/test/rails_app/config/locales/es.yml +10 -0
  71. data/test/rails_app/config/routes.rb +67 -0
  72. data/test/rails_app/db/migrate/20141210070547_devise_create_users.rb +45 -0
  73. data/test/rails_app/db/schema.rb +35 -0
  74. data/test/rails_app/perf.rake +10 -0
  75. data/test/rails_app/public/404.html +26 -0
  76. data/test/rails_app/public/422.html +26 -0
  77. data/test/rails_app/public/500.html +26 -0
  78. data/test/rails_app/public/favicon.ico +0 -0
  79. data/test/rails_app/public/javascripts/application.js +2 -0
  80. data/test/rails_app/public/javascripts/controls.js +965 -0
  81. data/test/rails_app/public/javascripts/dragdrop.js +974 -0
  82. data/test/rails_app/public/javascripts/effects.js +1123 -0
  83. data/test/rails_app/public/javascripts/prototype.js +6001 -0
  84. data/test/rails_app/public/javascripts/rails.js +202 -0
  85. data/test/rails_app/public/stylesheets/.gitkeep +0 -0
  86. data/test/rails_app/script/rails +8 -0
  87. data/test/support/integration_case.rb +7 -0
  88. data/test/test_helper.rb +65 -0
  89. metadata +398 -0
@@ -0,0 +1,132 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+ require 'shellwords'
5
+
6
+ class TasksTest < ActiveSupport::TestCase
7
+
8
+ def setup
9
+ FileUtils.mkdir_p(rails_app_path('tmp'))
10
+ end
11
+
12
+ def teardown
13
+ FileUtils.rm_rf(rails_app_path('tmp'))
14
+ end
15
+
16
+ def run!(cmd)
17
+ puts "Running: #{cmd}"
18
+ out = `#{cmd}`
19
+ raise "Could not run #{cmd}, output: #{out}" unless $?.success?
20
+ out
21
+ end
22
+
23
+ def rake(cmd, options = {})
24
+ assert_success = options.key?(:assert_success) ? options[:assert_success] : true
25
+ env = options[:env] || {}
26
+ env_string = env.map {|key, value| "#{key.shellescape}=#{value.to_s.shellescape}" }.join(" ")
27
+ cmd = "env #{env_string} bundle exec rake -f perf.rake #{cmd} --trace"
28
+ puts "Running: #{cmd}"
29
+ result = Bundler.with_original_env { `cd '#{rails_app_path}' && #{cmd}` }
30
+ if assert_success
31
+ assert $?.success?, "Expected '#{cmd}' to return a success status.\nOutput: #{result}"
32
+ end
33
+
34
+ result
35
+ end
36
+
37
+ test 'library_branches' do
38
+ skip unless ENV['USING_RAILS_GIT']
39
+
40
+ env = { "TEST_COUNT" => 10, "DERAILED_SCRIPT_COUNT" => 2, "SHAS_TO_TEST" => "3054e1d584e7eca110c69a1f8423f2e0866abbf9,80f989aecece1a2b1830e9c953e5887421b52d3c"}
41
+ puts rake "perf:library", { env: env }
42
+ end
43
+
44
+ test 'hitting authenticated devise apps' do
45
+ env = { "PATH_TO_HIT" => "authenticated", "USE_AUTH" => "true", "TEST_COUNT" => "2" }
46
+ result = rake 'perf:test', env: env
47
+ assert_match 'Auth: true', result
48
+
49
+ env["USE_SERVER"] = "webrick"
50
+ result = rake 'perf:test', env: env
51
+ assert_match 'Auth: true', result
52
+ assert_match 'Server: "webrick"', result
53
+ end
54
+
55
+ test 'authenticate with a custom user' do
56
+ env = { "AUTH_CUSTOM_USER" => "true", "PATH_TO_HIT" => "authenticated", "USE_AUTH" => "true", "TEST_COUNT" => "2" }
57
+ result = rake 'perf:test', env: env
58
+ assert_match 'Auth: true', result
59
+ end
60
+
61
+ test 'test' do
62
+ rake "perf:test"
63
+ end
64
+
65
+ test 'app' do
66
+ skip unless ENV['USING_RAILS_GIT']
67
+ run!("cd #{rails_app_path} && git init . && git add . && git commit -m first && git commit --allow-empty -m second")
68
+ env = { "TEST_COUNT" => 10, "DERAILED_SCRIPT_COUNT" => 2 }
69
+ puts rake "perf:app", { env: env }
70
+ end
71
+
72
+ test 'TEST_COUNT' do
73
+ result = rake "perf:test", env: { "TEST_COUNT" => 1 }
74
+ assert_match "1 derailed requests", result
75
+ end
76
+
77
+ test 'WARM_COUNT' do
78
+ result = rake "perf:test", env: { "WARM_COUNT" => 1 }
79
+ assert_match "Warming up app:", result
80
+ end
81
+
82
+ test 'PATH_TO_HIT' do
83
+ env = { "PATH_TO_HIT" => 'foo', "TEST_COUNT" => "2" }
84
+ result = rake "perf:test", env: env
85
+ assert_match 'Endpoint: "foo"', result
86
+
87
+ env["USE_SERVER"] = "webrick"
88
+ result = rake "perf:test", env: env
89
+ assert_match 'Endpoint: "foo"', result
90
+ assert_match 'Server: "webrick"', result
91
+ end
92
+
93
+ test 'HTTP headers' do
94
+ env = {
95
+ "PATH_TO_HIT" => 'foo_secret',
96
+ "TEST_COUNT" => "2",
97
+ "HTTP_AUTHORIZATION" => "Basic #{Base64.encode64("admin:secret")}",
98
+ "HTTP_CACHE_CONTROL" => "no-cache"
99
+ }
100
+ result = rake "perf:test", env: env
101
+ assert_match 'Endpoint: "foo_secret"', result
102
+ assert_match 'HTTP headers: {"Authorization"=>"Basic YWRtaW46c2VjcmV0\n", "Cache-Control"=>"no-cache"}', result
103
+
104
+ env["USE_SERVER"] = "webrick"
105
+ result = rake "perf:test", env: env
106
+ assert_match 'HTTP headers: {"Authorization"=>"Basic YWRtaW46c2VjcmV0\n", "Cache-Control"=>"no-cache"}', result
107
+ end
108
+
109
+ test 'USE_SERVER' do
110
+ result = rake "perf:test", env: { "USE_SERVER" => 'webrick', "TEST_COUNT" => "2" }
111
+ assert_match 'Server: "webrick"', result
112
+ end
113
+
114
+ test '' do
115
+ end
116
+
117
+ test 'objects' do
118
+ rake "perf:objects"
119
+ end
120
+
121
+ test 'mem' do
122
+ rake "perf:mem"
123
+ end
124
+
125
+ test 'mem_over_time' do
126
+ rake "perf:mem_over_time"
127
+ end
128
+
129
+ test 'ips' do
130
+ rake "perf:mem_over_time"
131
+ end
132
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
4
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
5
+
6
+ require File.expand_path('../config/application', __FILE__)
7
+ require 'rake'
8
+
9
+ Dummy::Application.load_tasks
File without changes
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationController < ActionController::Base
4
+ if respond_to?(:before_filter) && !respond_to?(:before_action)
5
+ class << self
6
+ alias :before_action :before_filter
7
+ end
8
+ end
9
+
10
+ protect_from_forgery
11
+ before_action :pull_out_locale
12
+
13
+
14
+ def pull_out_locale
15
+ I18n.locale = params[:locale] if params[:locale].present?
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AuthenticatedController < ApplicationController
4
+ before_action :authenticate_user!
5
+
6
+ def index
7
+ end
8
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ class PagesController < ApplicationController
4
+ http_basic_authenticate_with name: "admin", password: "secret", only: :secret
5
+
6
+ def index
7
+ end
8
+
9
+ def secret
10
+ render action: 'index'
11
+ end
12
+
13
+ private
14
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApplicationHelper
4
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AuthenticatedHelper
4
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class User < ActiveRecord::Base
4
+ # Include default devise modules. Others available are:
5
+ # :confirmable, :lockable, :timeoutable and :omniauthable
6
+ devise :database_authenticatable, :recoverable,
7
+ :registerable, :rememberable, :timeoutable,
8
+ :trackable, :validatable
9
+
10
+ # Setup accessible (or protected) attributes for your model
11
+ # attr_accessible :email, :password, :password_confirmation, :remember_me
12
+ # attr_accessible :title, :body
13
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%# stylesheet_link_tag :all %>
6
+ <%# javascript_include_tag :defaults %>
7
+ <%= csrf_meta_tag %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is used by Rack-based servers to start the application.
4
+
5
+ require ::File.expand_path('../config/environment', __FILE__)
6
+ run Dummy::Application
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('../boot', __FILE__)
4
+
5
+ require "active_model/railtie"
6
+ require "active_record/railtie"
7
+ require "action_controller/railtie"
8
+ require "action_view/railtie"
9
+ require "action_mailer/railtie"
10
+
11
+ Bundler.require :default
12
+ require 'devise'
13
+
14
+ module Dummy
15
+ class Application < Rails::Application
16
+ config.load_defaults Rails.version.to_f
17
+
18
+ config.action_mailer.default_url_options = { host: 'localhost:3000' }
19
+
20
+ # Settings in config/environments/* take precedence over those specified here.
21
+ # Application configuration should go into files in config/initializers
22
+ # -- all .rb files in that directory are automatically loaded.
23
+
24
+ # Custom directories with classes and modules you want to be autoloadable.
25
+ # config.autoload_paths += %W(#{config.root}/extras)
26
+
27
+ # Only load the plugins named here, in the order given (default is alphabetical).
28
+ # :all can be used as a placeholder for all plugins not explicitly named.
29
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
30
+
31
+ # Activate observers that should always be running.
32
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
33
+
34
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
35
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
36
+ # config.time_zone = 'Central Time (US & Canada)'
37
+
38
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
39
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
40
+ # config.i18n.default_locale = :de
41
+
42
+ # JavaScript files you want as :defaults (application.js is always included).
43
+ # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
44
+
45
+ # Configure the default encoding used in templates for Ruby 1.9.
46
+ config.encoding = "utf-8"
47
+
48
+ # Configure sensitive parameters which will be filtered from the log file.
49
+ config.filter_parameters += [:password]
50
+ config.serve_static_assets = true
51
+ end
52
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubygems'
4
+ gemfile = File.expand_path('../../../../Gemfile', __FILE__)
5
+
6
+ if File.exist?(gemfile)
7
+ ENV['BUNDLE_GEMFILE'] ||= gemfile
8
+ require 'bundler'
9
+ Bundler.setup
10
+ end
11
+
12
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,22 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+
4
+ default: &default
5
+ adapter: sqlite3
6
+ pool: 5
7
+ timeout: 5000
8
+
9
+ development:
10
+ <<: *default
11
+ database: db/development.sqlite3
12
+
13
+ # Warning: The database defined as "test" will be erased and
14
+ # re-generated from your development database when you run "rake".
15
+ # Do not set this db to the same as development or production.
16
+ test:
17
+ <<: *default
18
+ database: db/test.sqlite3
19
+
20
+ production:
21
+ <<: *default
22
+ database: db/production.sqlite3
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Load the rails application
4
+ require File.expand_path('../application', __FILE__)
5
+
6
+ # Initialize the rails application
7
+ if Rails.application.config.active_record.sqlite3.respond_to?(:represent_boolean_as_integer)
8
+ Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
9
+ end
10
+
11
+ Dummy::Application.initialize!
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ Dummy::Application.configure do
4
+ # Settings specified here will take precedence over those in config/application.rb
5
+
6
+ # In the development environment your application's code is reloaded on
7
+ # every request. This slows down response time but is perfect for development
8
+ # since you don't have to restart the webserver when you make code changes.
9
+ config.cache_classes = false
10
+
11
+ # Log error messages when you accidentally call methods on nil.
12
+ config.whiny_nils = true
13
+
14
+ # Show full error reports and disable caching
15
+ config.consider_all_requests_local = true
16
+ config.action_controller.perform_caching = false
17
+
18
+ # Don't care if the mailer can't send
19
+ config.action_mailer.raise_delivery_errors = false
20
+
21
+ # Print deprecation notices to the Rails logger
22
+ config.active_support.deprecation = :log
23
+
24
+ # Only use best-standards-support built into browsers
25
+ config.action_dispatch.best_standards_support = :builtin
26
+ end
27
+
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ Dummy::Application.configure do
4
+ # Settings specified here will take precedence over those in config/application.rb
5
+
6
+ # The production environment is meant for finished, "live" apps.
7
+ # Code is not reloaded between requests
8
+ config.cache_classes = true
9
+
10
+ # Full error reports are disabled and caching is turned on
11
+ config.consider_all_requests_local = false
12
+ config.action_controller.perform_caching = true
13
+
14
+ # Specifies the header that your server uses for sending files
15
+ config.action_dispatch.x_sendfile_header = "X-Sendfile"
16
+
17
+ # For nginx:
18
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
19
+
20
+ # If you have no front-end server that supports something like X-Sendfile,
21
+ # just comment this out and Rails will serve the files
22
+
23
+ # See everything in the log (default is :info)
24
+ # config.log_level = :debug
25
+
26
+ # Use a different logger for distributed setups
27
+ # config.logger = SyslogLogger.new
28
+
29
+ # Use a different cache store in production
30
+ # config.cache_store = :mem_cache_store
31
+
32
+ # Disable Rails's static asset server
33
+ # In production, Apache or nginx will already do this
34
+ config.serve_static_assets = false
35
+
36
+ # Enable serving of images, stylesheets, and javascripts from an asset server
37
+ # config.action_controller.asset_host = "http://assets.example.com"
38
+
39
+ # Disable delivery errors, bad email addresses will be ignored
40
+ # config.action_mailer.raise_delivery_errors = false
41
+
42
+ # Enable threaded mode
43
+ # config.threadsafe!
44
+
45
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
46
+ # the I18n.default_locale when a translation can not be found)
47
+ config.i18n.fallbacks = true
48
+
49
+ # Send deprecation notices to registered listeners
50
+ config.active_support.deprecation = :notify
51
+ end