derailed_benchmarks 0.0.0 → 1.0.0
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.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/.travis.yml +13 -0
- data/CHANGELOG.md +13 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +133 -0
- data/README.md +415 -51
- data/Rakefile +27 -0
- data/bin/derailed +84 -0
- data/derailed_benchmarks.gemspec +6 -1
- data/lib/derailed_benchmarks.rb +32 -0
- data/lib/derailed_benchmarks/auth_helper.rb +32 -0
- data/lib/derailed_benchmarks/auth_helpers/devise.rb +36 -0
- data/lib/derailed_benchmarks/core_ext/kernel_require.rb +72 -0
- data/lib/derailed_benchmarks/require_tree.rb +45 -0
- data/lib/derailed_benchmarks/tasks.rb +71 -110
- data/lib/derailed_benchmarks/version.rb +1 -1
- data/test/derailed_benchmarks/core_ext/kernel_require_test.rb +29 -0
- data/test/derailed_benchmarks/require_tree_test.rb +54 -0
- data/test/derailed_test.rb +12 -0
- data/test/fixtures/require/child_one.rb +4 -0
- data/test/fixtures/require/child_two.rb +9 -0
- data/test/fixtures/require/parent_one.rb +6 -0
- data/test/fixtures/require/raise_child.rb +4 -0
- data/test/fixtures/require/relative_child.rb +2 -0
- data/test/integration/tasks_test.rb +82 -0
- data/test/rails_app/Rakefile +7 -0
- data/test/rails_app/app/assets/javascripts/authenticated.js +2 -0
- data/test/rails_app/app/assets/stylesheets/authenticated.css +4 -0
- data/test/rails_app/app/controllers/application_controller.rb +9 -0
- data/test/rails_app/app/controllers/authenticated_controller.rb +12 -0
- data/test/rails_app/app/controllers/pages_controller.rb +7 -0
- data/test/rails_app/app/helpers/application_helper.rb +2 -0
- data/test/rails_app/app/helpers/authenticated_helper.rb +2 -0
- data/test/rails_app/app/models/user.rb +11 -0
- data/test/rails_app/app/views/authenticated/index.html.erb +1 -0
- data/test/rails_app/app/views/layouts/application.html.erb +14 -0
- data/test/rails_app/app/views/pages/index.html.erb +1 -0
- data/test/rails_app/config.ru +4 -0
- data/test/rails_app/config/application.rb +48 -0
- data/test/rails_app/config/boot.rb +10 -0
- data/test/rails_app/config/database.yml +22 -0
- data/test/rails_app/config/environment.rb +5 -0
- data/test/rails_app/config/environments/development.rb +25 -0
- data/test/rails_app/config/environments/production.rb +49 -0
- data/test/rails_app/config/environments/test.rb +35 -0
- data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails_app/config/initializers/devise.rb +256 -0
- data/test/rails_app/config/initializers/inflections.rb +10 -0
- data/test/rails_app/config/initializers/mime_types.rb +5 -0
- data/test/rails_app/config/initializers/secret_token.rb +7 -0
- data/test/rails_app/config/initializers/session_store.rb +8 -0
- data/test/rails_app/config/locales/devise.en.yml +59 -0
- data/test/rails_app/config/locales/en.yml +9 -0
- data/test/rails_app/config/locales/es.yml +10 -0
- data/test/rails_app/config/routes.rb +64 -0
- data/test/rails_app/db/migrate/20141210070547_devise_create_users.rb +42 -0
- data/test/rails_app/db/schema.rb +34 -0
- data/test/rails_app/perf.rake +4 -0
- data/test/rails_app/public/404.html +26 -0
- data/test/rails_app/public/422.html +26 -0
- data/test/rails_app/public/500.html +26 -0
- data/test/rails_app/public/favicon.ico +0 -0
- data/test/rails_app/public/javascripts/application.js +2 -0
- data/test/rails_app/public/javascripts/controls.js +965 -0
- data/test/rails_app/public/javascripts/dragdrop.js +974 -0
- data/test/rails_app/public/javascripts/effects.js +1123 -0
- data/test/rails_app/public/javascripts/prototype.js +6001 -0
- data/test/rails_app/public/javascripts/rails.js +202 -0
- data/test/rails_app/public/stylesheets/.gitkeep +0 -0
- data/test/rails_app/script/rails +6 -0
- data/test/support/integration_case.rb +5 -0
- data/test/test_helper.rb +53 -0
- metadata +198 -6
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class KernelRequireTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
setup do
|
6
|
+
require 'derailed_benchmarks/core_ext/kernel_require'
|
7
|
+
GC.disable
|
8
|
+
end
|
9
|
+
|
10
|
+
teardown do
|
11
|
+
GC.enable
|
12
|
+
end
|
13
|
+
|
14
|
+
def assert_node_in_parent(file_name, parent)
|
15
|
+
file = fixtures_dir(File.join("require", file_name))
|
16
|
+
node = parent[file]
|
17
|
+
assert node, "Expected:\n#{parent.children}\nto include:\n#{file.inspect}"
|
18
|
+
assert node.cost < parent.cost, "Expected:\n#{node.inspect}\nto cost less than:\n#{parent.inspect}" unless parent == TOP_REQUIRE
|
19
|
+
node
|
20
|
+
end
|
21
|
+
|
22
|
+
test "core extension profiles useage" do
|
23
|
+
require fixtures_dir("require/parent_one.rb")
|
24
|
+
parent = assert_node_in_parent("parent_one.rb", TOP_REQUIRE)
|
25
|
+
child_one = assert_node_in_parent("child_one.rb", parent)
|
26
|
+
child_two = assert_node_in_parent("child_two.rb", parent)
|
27
|
+
rse_child = assert_node_in_parent("raise_child.rb", child_two)
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RequireTree < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def tree(name)
|
6
|
+
DerailedBenchmarks::RequireTree.new(name)
|
7
|
+
end
|
8
|
+
|
9
|
+
test "default_cost" do
|
10
|
+
parent = tree("parent")
|
11
|
+
assert_equal 0, parent.cost
|
12
|
+
value = rand(0..100)
|
13
|
+
parent.cost = value
|
14
|
+
|
15
|
+
assert_equal value, parent.cost
|
16
|
+
end
|
17
|
+
|
18
|
+
test "stores child" do
|
19
|
+
parent = tree("parent")
|
20
|
+
child = tree("child")
|
21
|
+
parent << child
|
22
|
+
|
23
|
+
# [](name)
|
24
|
+
assert_equal child, parent["child"]
|
25
|
+
# children
|
26
|
+
assert_equal [child], parent.children
|
27
|
+
assert_equal [child], parent.sorted_children
|
28
|
+
end
|
29
|
+
|
30
|
+
test "sorts children" do
|
31
|
+
parent = tree("parent")
|
32
|
+
parent.cost = rand(5..10)
|
33
|
+
small = tree("small")
|
34
|
+
small.cost = rand(10..100)
|
35
|
+
|
36
|
+
large = tree("large")
|
37
|
+
large.cost = small.cost + 1
|
38
|
+
|
39
|
+
parent << small
|
40
|
+
parent << large
|
41
|
+
|
42
|
+
expected = [large, small]
|
43
|
+
assert_equal expected, parent.sorted_children
|
44
|
+
|
45
|
+
expected = <<-OUT
|
46
|
+
parent: #{ parent.cost.round(4) } mb
|
47
|
+
large: #{ large.cost.round(4) } mb
|
48
|
+
small: #{ small.cost.round(4) } mb
|
49
|
+
OUT
|
50
|
+
capture = StringIO.new
|
51
|
+
parent.print_sorted_children(0, capture)
|
52
|
+
assert_equal expected, capture.string
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class DerailedBenchmarksTest < ActiveSupport::TestCase
|
4
|
+
test "truth" do
|
5
|
+
assert_kind_of Module, DerailedBenchmarks
|
6
|
+
end
|
7
|
+
|
8
|
+
test "gem_is_bundled?" do
|
9
|
+
assert DerailedBenchmarks.gem_is_bundled?("rack")
|
10
|
+
refute DerailedBenchmarks.gem_is_bundled?("wicked")
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'shellwords'
|
3
|
+
|
4
|
+
class TasksTest < ActiveSupport::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
FileUtils.mkdir_p(rails_app_path('tmp'))
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
FileUtils.remove_entry_secure(rails_app_path('tmp'))
|
12
|
+
end
|
13
|
+
|
14
|
+
def rake(cmd, options = {})
|
15
|
+
assert_success = options[:assert_success] || true
|
16
|
+
env = options[:env] || {}
|
17
|
+
env_string = env.map {|key, value| "#{key.shellescape}=#{value.to_s.shellescape}" }.join(" ")
|
18
|
+
cmd = "env #{env_string} bundle exec rake -f perf.rake #{cmd} --trace"
|
19
|
+
puts "Running: #{cmd}"
|
20
|
+
result = `cd #{rails_app_path} && #{cmd}`
|
21
|
+
if assert_success
|
22
|
+
assert $?.success?, "Expected '#{cmd}' to return a success status.\nOutput: #{result}"
|
23
|
+
end
|
24
|
+
|
25
|
+
result
|
26
|
+
end
|
27
|
+
|
28
|
+
test 'hitting authenticated devise apps' do
|
29
|
+
env = { "PATH_TO_HIT" => "authenticated", "USE_AUTH" => "true", "TEST_COUNT" => "2" }
|
30
|
+
result = rake 'perf:test', env: env
|
31
|
+
assert_match 'Auth: true', result
|
32
|
+
|
33
|
+
env["USE_SERVER"] = "webrick"
|
34
|
+
result = rake 'perf:test', env: env
|
35
|
+
assert_match 'Auth: true', result
|
36
|
+
assert_match 'Server: "webrick"', result
|
37
|
+
end
|
38
|
+
|
39
|
+
test 'test' do
|
40
|
+
rake "perf:test"
|
41
|
+
end
|
42
|
+
|
43
|
+
test 'TEST_COUNT' do
|
44
|
+
result = rake "perf:test", env: { "TEST_COUNT" => 1 }
|
45
|
+
assert_match "1 requests", result
|
46
|
+
end
|
47
|
+
|
48
|
+
test 'PATH_TO_HIT' do
|
49
|
+
env = { "PATH_TO_HIT" => 'foo', "TEST_COUNT" => "2" }
|
50
|
+
result = rake "perf:test", env: env
|
51
|
+
assert_match 'Endpoint: "foo"', result
|
52
|
+
|
53
|
+
env["USE_SERVER"] = "webrick"
|
54
|
+
result = rake "perf:test", env: env
|
55
|
+
assert_match 'Endpoint: "foo"', result
|
56
|
+
assert_match 'Server: "webrick"', result
|
57
|
+
end
|
58
|
+
|
59
|
+
test 'USE_SERVER' do
|
60
|
+
result = rake "perf:test", env: { "USE_SERVER" => 'webrick', "TEST_COUNT" => "2" }
|
61
|
+
assert_match 'Server: "webrick"', result
|
62
|
+
end
|
63
|
+
|
64
|
+
test '' do
|
65
|
+
end
|
66
|
+
|
67
|
+
test 'objects' do
|
68
|
+
rake "perf:objects"
|
69
|
+
end
|
70
|
+
|
71
|
+
test 'mem' do
|
72
|
+
rake "perf:mem"
|
73
|
+
end
|
74
|
+
|
75
|
+
test 'ram_over_time' do
|
76
|
+
rake "perf:ram_over_time"
|
77
|
+
end
|
78
|
+
|
79
|
+
test 'ips' do
|
80
|
+
rake "perf:ram_over_time"
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require File.expand_path('../config/application', __FILE__)
|
5
|
+
require 'rake'
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class User < ActiveRecord::Base
|
2
|
+
# Include default devise modules. Others available are:
|
3
|
+
# :confirmable, :lockable, :timeoutable and :omniauthable
|
4
|
+
devise :database_authenticatable, :recoverable,
|
5
|
+
:registerable, :rememberable, :timeoutable,
|
6
|
+
:trackable, :validatable
|
7
|
+
|
8
|
+
# Setup accessible (or protected) attributes for your model
|
9
|
+
# attr_accessible :email, :password, :password_confirmation, :remember_me
|
10
|
+
# attr_accessible :title, :body
|
11
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
sup
|
@@ -0,0 +1 @@
|
|
1
|
+
ohai
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require "active_model/railtie"
|
4
|
+
require "active_record/railtie"
|
5
|
+
require "action_controller/railtie"
|
6
|
+
require "action_view/railtie"
|
7
|
+
require "action_mailer/railtie"
|
8
|
+
|
9
|
+
Bundler.require :default
|
10
|
+
require 'devise'
|
11
|
+
|
12
|
+
module Dummy
|
13
|
+
class Application < Rails::Application
|
14
|
+
config.action_mailer.default_url_options = { host: 'localhost:3000' }
|
15
|
+
|
16
|
+
# Settings in config/environments/* take precedence over those specified here.
|
17
|
+
# Application configuration should go into files in config/initializers
|
18
|
+
# -- all .rb files in that directory are automatically loaded.
|
19
|
+
|
20
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
21
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
22
|
+
|
23
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
24
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
25
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
26
|
+
|
27
|
+
# Activate observers that should always be running.
|
28
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
29
|
+
|
30
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
31
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
32
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
33
|
+
|
34
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
35
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
36
|
+
# config.i18n.default_locale = :de
|
37
|
+
|
38
|
+
# JavaScript files you want as :defaults (application.js is always included).
|
39
|
+
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
|
40
|
+
|
41
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
42
|
+
config.encoding = "utf-8"
|
43
|
+
|
44
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
45
|
+
config.filter_parameters += [:password]
|
46
|
+
config.serve_static_assets = true
|
47
|
+
end
|
48
|
+
end
|
@@ -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,25 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the webserver when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
18
|
+
|
19
|
+
# Print deprecation notices to the Rails logger
|
20
|
+
config.active_support.deprecation = :log
|
21
|
+
|
22
|
+
# Only use best-standards-support built into browsers
|
23
|
+
config.action_dispatch.best_standards_support = :builtin
|
24
|
+
end
|
25
|
+
|