derailed_benchmarks 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +3 -0
- data/.travis.yml +23 -0
- data/Appraisals +26 -0
- data/CHANGELOG.md +4 -0
- data/README.md +14 -3
- data/derailed_benchmarks.gemspec +4 -3
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/rails_3_2.gemfile +13 -0
- data/gemfiles/rails_4_0.gemfile +13 -0
- data/gemfiles/rails_4_1.gemfile +13 -0
- data/gemfiles/rails_4_2.gemfile +13 -0
- data/gemfiles/rails_5_0.gemfile +13 -0
- data/gemfiles/rails_5_1.gemfile +13 -0
- data/lib/derailed_benchmarks/tasks.rb +16 -32
- data/lib/derailed_benchmarks/version.rb +1 -1
- data/test/integration/tasks_test.rb +17 -1
- data/test/rails_app/app/controllers/application_controller.rb +7 -1
- data/test/rails_app/app/controllers/authenticated_controller.rb +0 -6
- data/test/rails_app/app/controllers/pages_controller.rb +5 -0
- data/test/rails_app/config/routes.rb +1 -0
- data/test/rails_app/db/migrate/20141210070547_devise_create_users.rb +2 -1
- metadata +25 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 689f372f6e0a6bd25ac8b3ca6c9a1378459020ba61044aa4fa3dca67911a2363
|
4
|
+
data.tar.gz: c02c9c53ca5aa3e6469ea830534dc2c9a623f9c2bf105973df04c494920cd160
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9191351090e9da616024a53040fce8f80331982fedcd165b36c19291ed59261fa0bb2afb61703d687145315b6e57eefbbaef9557b926b1cd0ff2b9d807f6443
|
7
|
+
data.tar.gz: 330e785a95650ac8163af8f4eb06d73468541157d9836f4c433a1852b21731422703eba070b96f514ef6b933772fc0f883e1ff2fe0718e685030834a1402a778
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -4,10 +4,33 @@ rvm:
|
|
4
4
|
- 2.3
|
5
5
|
- 2.4.0
|
6
6
|
- ruby-head
|
7
|
+
gemfile:
|
8
|
+
- gemfiles/rails_3_2.gemfile
|
9
|
+
- gemfiles/rails_4_0.gemfile
|
10
|
+
- gemfiles/rails_4_1.gemfile
|
11
|
+
- gemfiles/rails_4_2.gemfile
|
12
|
+
- gemfiles/rails_5_0.gemfile
|
13
|
+
- gemfiles/rails_5_1.gemfile
|
7
14
|
|
8
15
|
before_install:
|
9
16
|
- gem install bundler
|
10
17
|
|
11
18
|
matrix:
|
19
|
+
# Ruby 2.4 doesn't work with devise + rails 3/4, so just skip the builds to
|
20
|
+
# avoid travis runs we expect to fail. This is due to the Integer/Fixnum
|
21
|
+
# change if I am not mistaken.
|
22
|
+
exclude:
|
23
|
+
- rvm: 2.4.0
|
24
|
+
gemfile: gemfiles/rails_3_2.gemfile
|
25
|
+
- rvm: 2.4.0
|
26
|
+
gemfile: gemfiles/rails_4_0.gemfile
|
27
|
+
- rvm: 2.4.0
|
28
|
+
gemfile: gemfiles/rails_4_1.gemfile
|
29
|
+
- rvm: ruby-head
|
30
|
+
gemfile: gemfiles/rails_3_2.gemfile
|
31
|
+
- rvm: ruby-head
|
32
|
+
gemfile: gemfiles/rails_4_0.gemfile
|
33
|
+
- rvm: ruby-head
|
34
|
+
gemfile: gemfiles/rails_4_1.gemfile
|
12
35
|
allow_failures:
|
13
36
|
- rvm: ruby-head
|
data/Appraisals
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
appraise "rails-3-2" do
|
5
|
+
gem "rails", "~> 3.2.0"
|
6
|
+
end
|
7
|
+
|
8
|
+
appraise "rails-4-0" do
|
9
|
+
gem "rails", "~> 4.0.0"
|
10
|
+
end
|
11
|
+
|
12
|
+
appraise "rails-4-1" do
|
13
|
+
gem "rails", "~> 4.1.0"
|
14
|
+
end
|
15
|
+
|
16
|
+
appraise "rails-4-2" do
|
17
|
+
gem "rails", "~> 4.2.0"
|
18
|
+
end
|
19
|
+
|
20
|
+
appraise "rails-5-0" do
|
21
|
+
gem "rails", "~> 5.0.0"
|
22
|
+
end
|
23
|
+
|
24
|
+
appraise "rails-5-1" do
|
25
|
+
gem "rails", "~> 5.1.0"
|
26
|
+
end
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -5,6 +5,7 @@ A series of things you can use to benchmark a Rails or Ruby app.
|
|
5
5
|
![](http://media.giphy.com/media/lfbxexWy71b6U/giphy.gif)
|
6
6
|
|
7
7
|
[![Build Status](https://travis-ci.org/schneems/derailed_benchmarks.svg)](https://travis-ci.org/schneems/derailed_benchmarks)
|
8
|
+
[![Help Contribute to Open Source](https://www.codetriage.com/schneems/derailed_benchmarks/badges/users.svg)](https://www.codetriage.com/schneems/derailed_benchmarks)
|
8
9
|
|
9
10
|
## Compatibility/Requirements
|
10
11
|
|
@@ -86,7 +87,7 @@ By default this task will only return results from the `:default` and `"producti
|
|
86
87
|
$ bundle exec derailed bundle:mem development
|
87
88
|
```
|
88
89
|
|
89
|
-
You can use `CUT_OFF=0.3` to only show files that have above a certain memory
|
90
|
+
You can use `CUT_OFF=0.3` to only show files that have above a certain memory usage, this can be used to help eliminate noise.
|
90
91
|
|
91
92
|
Note: This method won't include files in your own app, only items in your Gemfile. For that you'll need to use `bundle exec derailed exec mem`. See below for more info.
|
92
93
|
|
@@ -318,7 +319,7 @@ TOP: 54.1836 MiB
|
|
318
319
|
|
319
320
|
You can use `CUT_OFF=0.3` to only show files that have above a certain memory useage, this can be used to help eliminate noise.
|
320
321
|
|
321
|
-
If your application code is
|
322
|
+
If your application code is extremely large at boot consider using `$ derailed exec perf:objects` to debug low level object creation.
|
322
323
|
|
323
324
|
## My app is Slow
|
324
325
|
|
@@ -401,7 +402,7 @@ For tasks that are run a number of times you can set the number using `TEST_COUN
|
|
401
402
|
$ TEST_COUNT=100_000 bundle exec derailed exec perf:test
|
402
403
|
```
|
403
404
|
|
404
|
-
|
405
|
+
### Hitting a different endpoint with `PATH_TO_HIT`
|
405
406
|
|
406
407
|
By default tasks will hit your homepage `/`. If you want to hit a different url use `PATH_TO_HIT` for example if you wanted to go to `users/new` you can execute:
|
407
408
|
|
@@ -417,6 +418,16 @@ $ PATH_TO_HIT=http://subdomain.lvh.me:3000/users/new bundle exec derailed exec p
|
|
417
418
|
|
418
419
|
Beware that you cannot combine a full uri with `USE_SERVER`.
|
419
420
|
|
421
|
+
### Setting HTTP headers
|
422
|
+
|
423
|
+
You can specify HTTP headers by setting `HTTP_<header name>` variables. Example:
|
424
|
+
|
425
|
+
```
|
426
|
+
$ HTTP_AUTHORIZATION="Basic YWRtaW46c2VjcmV0\n" \
|
427
|
+
HTTP_USER_AGENT="Mozilla/5.0" \
|
428
|
+
PATH_TO_HIT=/foo_secret bundle exec derailed exec perf:ips
|
429
|
+
```
|
430
|
+
|
420
431
|
### Using a real web server with `USE_SERVER`
|
421
432
|
|
422
433
|
All tests are run without a webserver (directly using `Rack::Mock` by default), if you want to use a webserver set `USE_SERVER` to a Rack::Server compliant server, such as `webrick`.
|
data/derailed_benchmarks.gemspec
CHANGED
@@ -28,7 +28,8 @@ Gem::Specification.new do |gem|
|
|
28
28
|
gem.add_dependency "rake", "> 10", "< 13"
|
29
29
|
gem.add_dependency "thor", "~> 0.19"
|
30
30
|
|
31
|
-
gem.add_development_dependency "capybara",
|
32
|
-
gem.add_development_dependency "rails",
|
33
|
-
gem.add_development_dependency "devise",
|
31
|
+
gem.add_development_dependency "capybara", "~> 2"
|
32
|
+
gem.add_development_dependency "rails", "> 3", "< 6"
|
33
|
+
gem.add_development_dependency "devise", "> 3", "< 5"
|
34
|
+
gem.add_development_dependency "appraisal", "2.2.0"
|
34
35
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rails", "~> 3.2.0"
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem "sqlite3", platform: [:ruby, :mswin, :mingw]
|
9
|
+
gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.13", platform: :jruby
|
10
|
+
gem "test-unit", "~> 3.0"
|
11
|
+
end
|
12
|
+
|
13
|
+
gemspec path: "../"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rails", "~> 4.0.0"
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem "sqlite3", platform: [:ruby, :mswin, :mingw]
|
9
|
+
gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.13", platform: :jruby
|
10
|
+
gem "test-unit", "~> 3.0"
|
11
|
+
end
|
12
|
+
|
13
|
+
gemspec path: "../"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rails", "~> 4.1.0"
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem "sqlite3", platform: [:ruby, :mswin, :mingw]
|
9
|
+
gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.13", platform: :jruby
|
10
|
+
gem "test-unit", "~> 3.0"
|
11
|
+
end
|
12
|
+
|
13
|
+
gemspec path: "../"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rails", "~> 4.2.0"
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem "sqlite3", platform: [:ruby, :mswin, :mingw]
|
9
|
+
gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.13", platform: :jruby
|
10
|
+
gem "test-unit", "~> 3.0"
|
11
|
+
end
|
12
|
+
|
13
|
+
gemspec path: "../"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rails", "~> 5.0.0"
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem "sqlite3", platform: [:ruby, :mswin, :mingw]
|
9
|
+
gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.13", platform: :jruby
|
10
|
+
gem "test-unit", "~> 3.0"
|
11
|
+
end
|
12
|
+
|
13
|
+
gemspec path: "../"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rails", "~> 5.1.0"
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem "sqlite3", platform: [:ruby, :mswin, :mingw]
|
9
|
+
gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.13", platform: :jruby
|
10
|
+
gem "test-unit", "~> 3.0"
|
11
|
+
end
|
12
|
+
|
13
|
+
gemspec path: "../"
|
@@ -13,7 +13,7 @@ namespace :perf do
|
|
13
13
|
puts "Booting: #{Rails.env}"
|
14
14
|
|
15
15
|
%W{ . lib test config }.each do |file|
|
16
|
-
$LOAD_PATH << file
|
16
|
+
$LOAD_PATH << File.expand_path(file)
|
17
17
|
end
|
18
18
|
|
19
19
|
require 'application'
|
@@ -66,6 +66,19 @@ namespace :perf do
|
|
66
66
|
PATH_TO_HIT = ENV["PATH_TO_HIT"] || ENV['ENDPOINT'] || "/"
|
67
67
|
puts "Endpoint: #{ PATH_TO_HIT.inspect }"
|
68
68
|
|
69
|
+
HTTP_HEADER_PREFIX = "HTTP_".freeze
|
70
|
+
RACK_HTTP_HEADERS = ENV.select { |key| key.starts_with?(HTTP_HEADER_PREFIX) }
|
71
|
+
|
72
|
+
HTTP_HEADERS = RACK_HTTP_HEADERS.keys.inject({}) do |hash, rack_header_name|
|
73
|
+
# e.g. "HTTP_ACCEPT_CHARSET" -> "Accept-Charset"
|
74
|
+
header_name = rack_header_name[HTTP_HEADER_PREFIX.size..-1].split("_").map(&:downcase).map(&:capitalize).join("-")
|
75
|
+
hash[header_name] = RACK_HTTP_HEADERS[rack_header_name]
|
76
|
+
hash
|
77
|
+
end
|
78
|
+
puts "HTTP headers: #{HTTP_HEADERS}" unless HTTP_HEADERS.empty?
|
79
|
+
|
80
|
+
CURL_HTTP_HEADER_ARGS = HTTP_HEADERS.map { |http_header_name, value| "-H \"#{http_header_name}: #{value}\"" }.join(" ")
|
81
|
+
|
69
82
|
require 'rack/test'
|
70
83
|
require 'rack/file'
|
71
84
|
|
@@ -80,7 +93,7 @@ namespace :perf do
|
|
80
93
|
sleep 1
|
81
94
|
|
82
95
|
def call_app(path = File.join("/", PATH_TO_HIT))
|
83
|
-
cmd = "curl 'http://localhost:#{@port}#{path}' -s --fail 2>&1"
|
96
|
+
cmd = "curl #{CURL_HTTP_HEADER_ARGS} 'http://localhost:#{@port}#{path}' -s --fail 2>&1"
|
84
97
|
response = `#{cmd}`
|
85
98
|
raise "Bad request to #{cmd.inspect} Response:\n#{ response.inspect }" unless $?.success?
|
86
99
|
end
|
@@ -88,7 +101,7 @@ namespace :perf do
|
|
88
101
|
@app = Rack::MockRequest.new(DERAILED_APP)
|
89
102
|
|
90
103
|
def call_app
|
91
|
-
response = @app.get(PATH_TO_HIT)
|
104
|
+
response = @app.get(PATH_TO_HIT, RACK_HTTP_HEADERS)
|
92
105
|
raise "Bad request: #{ response.body }" unless response.status == 200
|
93
106
|
response
|
94
107
|
end
|
@@ -202,35 +215,6 @@ namespace :perf do
|
|
202
215
|
GC::Profiler.disable
|
203
216
|
end
|
204
217
|
|
205
|
-
task :foo => [:setup] do
|
206
|
-
require 'objspace'
|
207
|
-
call_app
|
208
|
-
|
209
|
-
before = Hash.new { 0 }
|
210
|
-
after = Hash.new { 0 }
|
211
|
-
after_size = Hash.new { 0 }
|
212
|
-
GC.start
|
213
|
-
GC.disable
|
214
|
-
|
215
|
-
TEST_COUNT.times { call_app }
|
216
|
-
|
217
|
-
rvalue_size = GC::INTERNAL_CONSTANTS[:RVALUE_SIZE]
|
218
|
-
ObjectSpace.each_object do |obj|
|
219
|
-
after[obj.class] += 1
|
220
|
-
memsize = ObjectSpace.memsize_of(obj) + rvalue_size
|
221
|
-
# compensate for API bug
|
222
|
-
memsize = rvalue_size if memsize > 100_000_000_000
|
223
|
-
after_size[obj.class] += memsize
|
224
|
-
end
|
225
|
-
|
226
|
-
require 'pp'
|
227
|
-
pp after.sort {|(k,v), (k2, v2)| v2 <=> v }
|
228
|
-
puts "========="
|
229
|
-
puts
|
230
|
-
puts
|
231
|
-
pp after_size.sort {|(k,v), (k2, v2)| v2 <=> v }
|
232
|
-
end
|
233
|
-
|
234
218
|
desc "outputs allocated object diff after app is called TEST_COUNT times"
|
235
219
|
task :allocated_objects => [:setup] do
|
236
220
|
call_app
|
@@ -17,7 +17,7 @@ class TasksTest < ActiveSupport::TestCase
|
|
17
17
|
env_string = env.map {|key, value| "#{key.shellescape}=#{value.to_s.shellescape}" }.join(" ")
|
18
18
|
cmd = "env #{env_string} bundle exec rake -f perf.rake #{cmd} --trace"
|
19
19
|
puts "Running: #{cmd}"
|
20
|
-
result = `cd #{rails_app_path} && #{cmd}`
|
20
|
+
result = `cd '#{rails_app_path}' && #{cmd}`
|
21
21
|
if assert_success
|
22
22
|
assert $?.success?, "Expected '#{cmd}' to return a success status.\nOutput: #{result}"
|
23
23
|
end
|
@@ -62,6 +62,22 @@ class TasksTest < ActiveSupport::TestCase
|
|
62
62
|
assert_match 'Server: "webrick"', result
|
63
63
|
end
|
64
64
|
|
65
|
+
test 'HTTP headers' do
|
66
|
+
env = {
|
67
|
+
"PATH_TO_HIT" => 'foo_secret',
|
68
|
+
"TEST_COUNT" => "2",
|
69
|
+
"HTTP_AUTHORIZATION" => "Basic #{Base64.encode64("admin:secret")}",
|
70
|
+
"HTTP_CACHE_CONTROL" => "no-cache"
|
71
|
+
}
|
72
|
+
result = rake "perf:test", env: env
|
73
|
+
assert_match 'Endpoint: "foo_secret"', result
|
74
|
+
assert_match 'HTTP headers: {"Authorization"=>"Basic YWRtaW46c2VjcmV0\n", "Cache-Control"=>"no-cache"}', result
|
75
|
+
|
76
|
+
env["USE_SERVER"] = "webrick"
|
77
|
+
result = rake "perf:test", env: env
|
78
|
+
assert_match 'HTTP headers: {"Authorization"=>"Basic YWRtaW46c2VjcmV0\n", "Cache-Control"=>"no-cache"}', result
|
79
|
+
end
|
80
|
+
|
65
81
|
test 'USE_SERVER' do
|
66
82
|
result = rake "perf:test", env: { "USE_SERVER" => 'webrick', "TEST_COUNT" => "2" }
|
67
83
|
assert_match 'Server: "webrick"', result
|
@@ -1,6 +1,12 @@
|
|
1
1
|
class ApplicationController < ActionController::Base
|
2
|
+
if respond_to?(:before_filter) && !respond_to?(:before_action)
|
3
|
+
class << self
|
4
|
+
alias :before_action :before_filter
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
2
8
|
protect_from_forgery
|
3
|
-
|
9
|
+
before_action :pull_out_locale
|
4
10
|
|
5
11
|
|
6
12
|
def pull_out_locale
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: derailed_benchmarks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Schneeman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: heapy
|
@@ -168,6 +168,20 @@ dependencies:
|
|
168
168
|
- - "<"
|
169
169
|
- !ruby/object:Gem::Version
|
170
170
|
version: '5'
|
171
|
+
- !ruby/object:Gem::Dependency
|
172
|
+
name: appraisal
|
173
|
+
requirement: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - '='
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: 2.2.0
|
178
|
+
type: :development
|
179
|
+
prerelease: false
|
180
|
+
version_requirements: !ruby/object:Gem::Requirement
|
181
|
+
requirements:
|
182
|
+
- - '='
|
183
|
+
- !ruby/object:Gem::Version
|
184
|
+
version: 2.2.0
|
171
185
|
description: " Go faster, off the Rails "
|
172
186
|
email:
|
173
187
|
- richard.schneeman+rubygems@gmail.com
|
@@ -178,12 +192,20 @@ extra_rdoc_files: []
|
|
178
192
|
files:
|
179
193
|
- ".gitignore"
|
180
194
|
- ".travis.yml"
|
195
|
+
- Appraisals
|
181
196
|
- CHANGELOG.md
|
182
197
|
- Gemfile
|
183
198
|
- README.md
|
184
199
|
- Rakefile
|
185
200
|
- bin/derailed
|
186
201
|
- derailed_benchmarks.gemspec
|
202
|
+
- gemfiles/.bundle/config
|
203
|
+
- gemfiles/rails_3_2.gemfile
|
204
|
+
- gemfiles/rails_4_0.gemfile
|
205
|
+
- gemfiles/rails_4_1.gemfile
|
206
|
+
- gemfiles/rails_4_2.gemfile
|
207
|
+
- gemfiles/rails_5_0.gemfile
|
208
|
+
- gemfiles/rails_5_1.gemfile
|
187
209
|
- lib/derailed_benchmarks.rb
|
188
210
|
- lib/derailed_benchmarks/auth_helper.rb
|
189
211
|
- lib/derailed_benchmarks/auth_helpers/devise.rb
|
@@ -267,7 +289,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
267
289
|
version: '0'
|
268
290
|
requirements: []
|
269
291
|
rubyforge_project:
|
270
|
-
rubygems_version: 2.6
|
292
|
+
rubygems_version: 2.7.6
|
271
293
|
signing_key:
|
272
294
|
specification_version: 4
|
273
295
|
summary: Benchmarks designed to performance test your ENTIRE site
|