derailed_benchmarks 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +7 -3
- data/README.md +31 -29
- data/derailed_benchmarks.gemspec +1 -0
- data/lib/derailed_benchmarks/auth_helpers/devise.rb +6 -3
- data/lib/derailed_benchmarks/tasks.rb +12 -3
- data/lib/derailed_benchmarks/version.rb +1 -1
- data/test/integration/tasks_test.rb +9 -3
- data/test/rails_app/perf.rake +4 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64e1d95c4daabc83570c1b4414e12e825d412224
|
4
|
+
data.tar.gz: a199e5d200e859f53aaeb25326d98325a860e959
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e0e983995112c57ce5925e75ff3e2fc1491ecad771f6445158688872625887710299e42cc20650a323f39c891459b99520b61475059efc97e8ebf5f2598dc70
|
7
|
+
data.tar.gz: b4f2972a0bb9cd35a6bd7b26fd070638b34c4a0e1f403bb2dee84f0dc913df5aae9dfb465a549097c55c9fa54504bc25dbc54f1455e3037da0c1f254e49b4423
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# A Log of Changes!
|
2
2
|
|
3
|
+
## [1.1.0] - 2015-09-09
|
4
|
+
|
5
|
+
- Set custom auth user using a lambda in perf.rake
|
6
|
+
- Changed `perf:ram_over_time` changed to `perf:mem_over_time`
|
7
|
+
- Fixed gem warnings
|
8
|
+
|
3
9
|
## [1.0.1] - 2015-20-06
|
4
10
|
|
5
11
|
- `bundle:mem` and similar tasks now keep track of duplicate requires and display them along side of memory requirements. This makes it easier to identify where components are used by multiple libraries
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
derailed_benchmarks (1.0
|
4
|
+
derailed_benchmarks (1.1.0)
|
5
5
|
benchmark-ips (~> 2)
|
6
6
|
get_process_mem (~> 0)
|
7
7
|
memory_profiler (~> 0)
|
8
8
|
rack (~> 1)
|
9
9
|
rake (~> 10)
|
10
|
+
thor (~> 0.19)
|
10
11
|
|
11
12
|
GEM
|
12
13
|
remote: https://rubygems.org/
|
@@ -40,7 +41,7 @@ GEM
|
|
40
41
|
multi_json (~> 1.0)
|
41
42
|
arel (3.0.3)
|
42
43
|
bcrypt (3.1.10)
|
43
|
-
benchmark-ips (2.
|
44
|
+
benchmark-ips (2.3.0)
|
44
45
|
builder (3.0.4)
|
45
46
|
capybara (2.4.4)
|
46
47
|
mime-types (>= 1.16)
|
@@ -64,7 +65,7 @@ GEM
|
|
64
65
|
mail (2.5.4)
|
65
66
|
mime-types (~> 1.16)
|
66
67
|
treetop (~> 1.4.8)
|
67
|
-
memory_profiler (0.9.
|
68
|
+
memory_profiler (0.9.4)
|
68
69
|
mime-types (1.25.1)
|
69
70
|
mini_portile (0.6.2)
|
70
71
|
multi_json (1.11.0)
|
@@ -131,3 +132,6 @@ DEPENDENCIES
|
|
131
132
|
rails (~> 3)
|
132
133
|
sqlite3
|
133
134
|
test-unit (~> 3.0)
|
135
|
+
|
136
|
+
BUNDLED WITH
|
137
|
+
1.10.6
|
data/README.md
CHANGED
@@ -4,6 +4,8 @@ A series of things you can use to benchmark a Rails or Ruby app.
|
|
4
4
|
|
5
5
|
![](http://media.giphy.com/media/lfbxexWy71b6U/giphy.gif)
|
6
6
|
|
7
|
+
[![Build Status](https://travis-ci.org/schneems/derailed_benchmarks.svg)](https://travis-ci.org/schneems/derailed_benchmarks)
|
8
|
+
|
7
9
|
## Compatibility/Requirements
|
8
10
|
|
9
11
|
This gem has been tested and is known to work with Rails 3.2+ using Ruby
|
@@ -33,7 +35,7 @@ While executing your commands you may need to use `bundle exec` before typing th
|
|
33
35
|
To use all profiling methods available also add:
|
34
36
|
|
35
37
|
```
|
36
|
-
gem
|
38
|
+
gem 'stackprof', group: :development
|
37
39
|
```
|
38
40
|
|
39
41
|
You must be using Ruby 2.1+ to install these libraries. If you're on an older version of Ruby, what are you waiting for?
|
@@ -55,13 +57,13 @@ For more information on the relationship between memory and performance please r
|
|
55
57
|
Each gem you add to your project can increase your memory at boot. You can get visibility into the total memory used by each gem in your Gemfile by running:
|
56
58
|
|
57
59
|
```
|
58
|
-
$ derailed bundle:mem
|
60
|
+
$ bundle exec derailed bundle:mem
|
59
61
|
```
|
60
62
|
|
61
63
|
This will load each of your gems in your Gemfile and see how much memory they consume when they are required. For example if you're using the `mail` gem. The output might look like this
|
62
64
|
|
63
65
|
```
|
64
|
-
$ derailed bundle:mem
|
66
|
+
$ bundle exec derailed bundle:mem
|
65
67
|
TOP: 54.1836 MiB
|
66
68
|
mail: 18.9688 MiB
|
67
69
|
mime/types: 17.4453 MiB
|
@@ -81,7 +83,7 @@ Here we can see that `mail` uses 18MiB, with the majority coming from `mime/type
|
|
81
83
|
By default this task will only return results from the `:default` and `"production"` groups. If you want a different group you can run with.
|
82
84
|
|
83
85
|
```
|
84
|
-
$ derailed bundle:mem development
|
86
|
+
$ bundle exec derailed bundle:mem development
|
85
87
|
```
|
86
88
|
|
87
89
|
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.
|
@@ -91,7 +93,7 @@ Note: This method won't include files in your own app, only items in your Gemfil
|
|
91
93
|
The same file may be required by several libraries, since Ruby only requires files once, the cost is only associated with the first library to require a file. To make this more visible duplicate entries will list all the parents they belong to. For example both `mail` and `fog` require `mime/types. So it may show up something like this in your app:
|
92
94
|
|
93
95
|
```
|
94
|
-
$ derailed bundle:mem
|
96
|
+
$ bundle exec derailed bundle:mem
|
95
97
|
TOP: 54.1836 MiB
|
96
98
|
mail: 18.9688 MiB
|
97
99
|
mime/types: 17.4453 MiB (Also required by: fog/storage)
|
@@ -111,7 +113,7 @@ fog/joyent: 0.7227 MiB
|
|
111
113
|
|
112
114
|
If you want to see everything that requires `fog/core` you can run `CUT_OFF=0 bundle exec derailed bundle:mem` to get the full output that you can then grep through manually.
|
113
115
|
|
114
|
-
Update: While `mime/types` looks
|
116
|
+
Update: While `mime/types` looks horrible in these examples, it's been fixed. You can add this to the top of your gemfile for free memory:
|
115
117
|
|
116
118
|
```ruby
|
117
119
|
gem 'mime-types', '~> 2.4.3', require: 'mime/types/columnar'
|
@@ -122,7 +124,7 @@ gem 'mime-types', '~> 2.4.3', require: 'mime/types/columnar'
|
|
122
124
|
To get more info about the objects, using [memory_profiler](https://github.com/SamSaffron/memory_profiler), created when your dependencies are required you can run:
|
123
125
|
|
124
126
|
```
|
125
|
-
$ derailed bundle:objects
|
127
|
+
$ bundle exec derailed bundle:objects
|
126
128
|
```
|
127
129
|
|
128
130
|
This will output detailed information about objects created while your dependencies are loaded
|
@@ -145,7 +147,7 @@ Once you identify a gem that creates a large amount of memory using `$ derailed
|
|
145
147
|
By default this task will only return results from the `:default` and `"production"` groups. If you want a different group you can run with.
|
146
148
|
|
147
149
|
```
|
148
|
-
$ derailed bundle:objects development
|
150
|
+
$ bundle exec derailed bundle:objects development
|
149
151
|
```
|
150
152
|
|
151
153
|
Note: This method won't include files in your own app, only items in your Gemfile. For that you'll need to use `derailed exec objects`. See below for more info.
|
@@ -155,7 +157,7 @@ Note: This method won't include files in your own app, only items in your Gemfil
|
|
155
157
|
|
156
158
|
This benchmarking will attempt to boot your Rails app and run benchmarks against it. Unlike the static benchmarking with `$ derailed bundle:*` these will include information about your specific app. The pro is you'll get more information and potentially identify problems in your app code, the con is that it requires you to be able to boot and run your application in a `production` environment locally, which for some apps is non-trivial.
|
157
159
|
|
158
|
-
You may want to check out [mini-profiler](https://github.com/MiniProfiler/rack-mini-profiler), here's a [mini-profiler walkthrough](http://www.justinweiss.com/blog/2015/05/11/a-new-way-to-understand-your-rails-apps-performance
|
160
|
+
You may want to check out [mini-profiler](https://github.com/MiniProfiler/rack-mini-profiler), here's a [mini-profiler walkthrough](http://www.justinweiss.com/blog/2015/05/11/a-new-way-to-understand-your-rails-apps-performance). It's great and does slightly different benchmarking than what you'll find here.
|
159
161
|
|
160
162
|
### Running in Production Locally.
|
161
163
|
|
@@ -167,7 +169,7 @@ For starters try booting into a console:
|
|
167
169
|
$ RAILS_ENV=production rails console
|
168
170
|
```
|
169
171
|
|
170
|
-
You may get errors, complaining about not being able to connect to the `production` database. For this, you can either create a local database with the name of your production database, or you can copy the info from your `development` group to your `production`
|
172
|
+
You may get errors, complaining about not being able to connect to the `production` database. For this, you can either create a local database with the name of your production database, or you can copy the info from your `development` group to your `production` group in your `database.yml`.
|
171
173
|
|
172
174
|
You may be missing environment variables expected in `production` such as `SECRET_KEY_BASE`. For those you can either commit them to your `.env` file (if you're using one). Or add them directly to the command:
|
173
175
|
|
@@ -183,10 +185,10 @@ $ RAILS_ENV=production rails server
|
|
183
185
|
|
184
186
|
You may need to disable enforcing SSL or other domain restrictions temporarially. If you do these, don't forget to add them back in before deploying any code (eek!).
|
185
187
|
|
186
|
-
You can get information from STDOUT if you're using `rails_12factor` gem, or from `
|
188
|
+
You can get information from STDOUT if you're using `rails_12factor` gem, or from `log/production.log` by running
|
187
189
|
|
188
190
|
```
|
189
|
-
$ tail -f
|
191
|
+
$ tail -f log/production.log
|
190
192
|
```
|
191
193
|
|
192
194
|
Once you've fixed all errors and you can run a server in production, you're almost there.
|
@@ -202,7 +204,7 @@ $ derailed exec --help
|
|
202
204
|
$ derailed exec perf:ips # iterations per second
|
203
205
|
$ derailed exec perf:mem # show memory usage caused by invoking require per gem
|
204
206
|
$ derailed exec perf:objects # profiles ruby allocation
|
205
|
-
$ derailed exec perf:
|
207
|
+
$ derailed exec perf:mem_over_time # outputs memory usage over time
|
206
208
|
$ derailed exec perf:test # hits the url TEST_COUNT times
|
207
209
|
```
|
208
210
|
|
@@ -214,13 +216,13 @@ Instead of going over each command we'll look at common problems and which comma
|
|
214
216
|
If your app appears to be leaking ever increasing amounts of memory, you'll want to first verify if it's an actual unbound "leak" or if it's just using more memory than you want. A true memory leak will increase memory use forever, most apps will increase memory use until they hit a "plateau". To diagnose this you can run:
|
215
217
|
|
216
218
|
```
|
217
|
-
$ derailed exec perf:
|
219
|
+
$ bundle exec derailed exec perf:mem_over_time
|
218
220
|
```
|
219
221
|
|
220
222
|
This will boot your app and hit it with requests and output the memory to stdout (and a file under ./tmp). It may look like this:
|
221
223
|
|
222
224
|
```
|
223
|
-
$ derailed exec perf:
|
225
|
+
$ bundle exec derailed exec perf:mem_over_time
|
224
226
|
Booting: production
|
225
227
|
Endpoint: "/"
|
226
228
|
PID: 78675
|
@@ -239,9 +241,9 @@ PID: 78675
|
|
239
241
|
Here we can see that while the memory use is increasing, it levels off around 183 MiB. You'll want to run this task using ever increasing values of `TEST_COUNT=` for example
|
240
242
|
|
241
243
|
```
|
242
|
-
$ TEST_COUNT=5000 derailed exec perf:
|
243
|
-
$ TEST_COUNT=10_000 derailed exec perf:
|
244
|
-
$ TEST_COUNT=20_000 derailed exec perf:
|
244
|
+
$ TEST_COUNT=5000 derailed exec perf:mem_over_time
|
245
|
+
$ TEST_COUNT=10_000 derailed exec perf:mem_over_time
|
246
|
+
$ TEST_COUNT=20_000 derailed exec perf:mem_over_time
|
245
247
|
```
|
246
248
|
|
247
249
|
Adjust your counts appropriately so you can get results in a reasonable amount of time. If your memory never levels off, congrats! You've got a memory leak! I recommend copying and pasting values from the file generated into google docs and graphing it so you can get a better sense of the slope of your line.
|
@@ -255,7 +257,7 @@ If you're pretty sure that there's a memory leak, but you can't confirm it using
|
|
255
257
|
If you've identified a memory leak, or you simply want to see where your memory use is coming from you'll want to use
|
256
258
|
|
257
259
|
```
|
258
|
-
$ derailed exec perf:objects
|
260
|
+
$ bundle exec derailed exec perf:objects
|
259
261
|
```
|
260
262
|
|
261
263
|
This task hits your app and uses memory_profiler to see where objects are created. You'll likely want to run once, then run it with a higher `TEST_COUNT` so that you can see hotspots where objects are created on __EVERY__ request versus just maybe on the first.
|
@@ -267,7 +269,7 @@ $ TEST_COUNT=10 derailed exec perf:objects
|
|
267
269
|
|
268
270
|
This is an expensive operation, so you likely want to keep the count lowish. Once you've identified a hotspot read [how ruby uses memory](http://www.sitepoint.com/ruby-uses-memory/) for some tips on reducing object allocations.
|
269
271
|
|
270
|
-
This is is similar to `$ derailed bundle:objects` however it includes objects created at runtime. It's much more useful for actual production performance debugging, the other is more useful for library authors to debug.
|
272
|
+
This is is similar to `$ bundle exec derailed bundle:objects` however it includes objects created at runtime. It's much more useful for actual production performance debugging, the other is more useful for library authors to debug.
|
271
273
|
|
272
274
|
|
273
275
|
### Memory Is large at boot.
|
@@ -278,7 +280,7 @@ This task does essentially the same thing, however it hits your app with one req
|
|
278
280
|
|
279
281
|
|
280
282
|
```
|
281
|
-
$ derailed exec perf:mem
|
283
|
+
$ bundle exec derailed exec perf:mem
|
282
284
|
|
283
285
|
TOP: 54.1836 MiB
|
284
286
|
mail: 18.9688 MiB
|
@@ -300,7 +302,7 @@ Well...aren't they all. If you've already looked into decreasing object allocati
|
|
300
302
|
One technique is to use a "sampling" stack profiler. This type of profiling looks at what method is being executed at a given interval and records it. At the end of execution it counts all the times a given method was being called and shows you the percent of time spent in each method. This is a very low overhead method to looking into execution time. Ruby 2.1+ has this available in gem form it's called [stackprof](https://github.com/tmm1/stackprof). As you guessed you can run this with derailed benchmarks, first add it to your gemfile `gem "stackprof", group: :development` then execute:
|
301
303
|
|
302
304
|
```
|
303
|
-
$ derailed exec perf:stackprof
|
305
|
+
$ bundle exec derailed exec perf:stackprof
|
304
306
|
==================================
|
305
307
|
Mode: cpu(1000)
|
306
308
|
Samples: 16067 (1.07% miss rate)
|
@@ -342,7 +344,7 @@ From here you can dig into individual methods.
|
|
342
344
|
Micro benchmarks might tell you at the code level how much faster something is, but what about the overall application speed. If you're trying to figure out how effective a performance change is to your application, it is useful to compare it to your existing app performance. To help you with that you can use:
|
343
345
|
|
344
346
|
```
|
345
|
-
$ derailed exec perf:ips
|
347
|
+
$ bundle exec derailed exec perf:ips
|
346
348
|
Endpoint: "/"
|
347
349
|
Calculating -------------------------------------
|
348
350
|
ips 1.000 i/100ms
|
@@ -355,7 +357,7 @@ This will hit an endpoint in your application using [benchmark-ips](https://gith
|
|
355
357
|
If you care you can also run pure benchmark (without ips):
|
356
358
|
|
357
359
|
```
|
358
|
-
$ derailed exec perf:test
|
360
|
+
$ bundle exec derailed exec perf:test
|
359
361
|
```
|
360
362
|
|
361
363
|
But I wouldn't, benchmark-ips is a better measure.
|
@@ -371,7 +373,7 @@ All the tasks accept configuration in the form of environment variables.
|
|
371
373
|
For tasks that are run a number of times you can set the number using `TEST_COUNT` for example:
|
372
374
|
|
373
375
|
```
|
374
|
-
$ derailed exec perf:test
|
376
|
+
$ TEST_COUNT=100_000 bundle exec derailed exec perf:test
|
375
377
|
```
|
376
378
|
|
377
379
|
## Hitting a different endpoint with `PATH_TO_HIT`
|
@@ -387,7 +389,7 @@ $ PATH_TO_HIT=/users/new derailed exec perf:mem
|
|
387
389
|
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`.
|
388
390
|
|
389
391
|
```
|
390
|
-
$ USE_SERVER=webrick derailed exec perf:mem
|
392
|
+
$ USE_SERVER=webrick bundle exec derailed exec perf:mem
|
391
393
|
```
|
392
394
|
|
393
395
|
Or
|
@@ -408,7 +410,7 @@ change this if your app doesn't run locally with `RAILS_ENV` set to
|
|
408
410
|
`production`. For example:
|
409
411
|
|
410
412
|
```
|
411
|
-
$ derailed exec perf:mem
|
413
|
+
$ RAILS_ENV=development bundle exec derailed exec perf:mem
|
412
414
|
```
|
413
415
|
|
414
416
|
## perf.rake
|
@@ -469,7 +471,7 @@ If you're trying to test an endpoint that has authentication you'll need to tell
|
|
469
471
|
To enable authentication in a test run with:
|
470
472
|
|
471
473
|
```
|
472
|
-
$ USE_AUTH=true derailed exec perf:mem
|
474
|
+
$ USE_AUTH=true bundle exec derailed exec perf:mem
|
473
475
|
```
|
474
476
|
|
475
477
|
See below how to customize authentication.
|
@@ -487,7 +489,7 @@ $ cat perf.rake
|
|
487
489
|
If you want you can customize the user that is logged in by setting that value in your `perf.rake` file.
|
488
490
|
|
489
491
|
```
|
490
|
-
DerailedBenchmarks.auth.user = User.find_or_create!(twitter: "schneems")
|
492
|
+
DerailedBenchmarks.auth.user = -> { User.find_or_create!(twitter: "schneems") }
|
491
493
|
```
|
492
494
|
|
493
495
|
You will need to provide a valid user, so depending on the validations you have in your `user.rb`, you may need to provide different parameters.
|
data/derailed_benchmarks.gemspec
CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |gem|
|
|
23
23
|
gem.add_dependency "benchmark-ips", "~> 2"
|
24
24
|
gem.add_dependency "rack", "~> 1"
|
25
25
|
gem.add_dependency "rake", "~> 10"
|
26
|
+
gem.add_dependency "thor", "~> 0.19"
|
26
27
|
|
27
28
|
gem.add_development_dependency "capybara", "~> 2"
|
28
29
|
gem.add_development_dependency "rails", "~> 3"
|
@@ -4,7 +4,7 @@ module DerailedBenchmarks
|
|
4
4
|
# Setup adds necessarry test methods, user provides a sample user.
|
5
5
|
# The authenticate method is called on every request when authentication is enabled
|
6
6
|
class Devise < AuthHelper
|
7
|
-
|
7
|
+
attr_writer :user
|
8
8
|
|
9
9
|
# Include devise test helpers and turn on test mode
|
10
10
|
# We need to do this on the class level
|
@@ -19,9 +19,12 @@ module DerailedBenchmarks
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def user
|
22
|
-
@user
|
22
|
+
if @user
|
23
|
+
@user = @user.call if @user.is_a?(Proc)
|
24
|
+
@user
|
25
|
+
else
|
23
26
|
password = SecureRandom.hex
|
24
|
-
User.first_or_create!(email: "#{SecureRandom.hex}@example.com", password: password, password_confirmation: password)
|
27
|
+
@user = User.first_or_create!(email: "#{SecureRandom.hex}@example.com", password: password, password_confirmation: password)
|
25
28
|
end
|
26
29
|
end
|
27
30
|
|
@@ -97,6 +97,8 @@ namespace :perf do
|
|
97
97
|
|
98
98
|
desc "hits the url TEST_COUNT times"
|
99
99
|
task :test => [:setup] do
|
100
|
+
require 'benchmark'
|
101
|
+
|
100
102
|
Benchmark.bm { |x|
|
101
103
|
x.report("#{TEST_COUNT} requests") {
|
102
104
|
TEST_COUNT.times {
|
@@ -145,15 +147,15 @@ namespace :perf do
|
|
145
147
|
TOP_REQUIRE.print_sorted_children
|
146
148
|
end
|
147
149
|
|
148
|
-
desc "outputs
|
149
|
-
task :
|
150
|
+
desc "outputs memory usage over time"
|
151
|
+
task :mem_over_time => [:setup] do
|
150
152
|
require 'get_process_mem'
|
151
153
|
puts "PID: #{Process.pid}"
|
152
154
|
ram = GetProcessMem.new
|
153
155
|
@keep_going = true
|
154
156
|
begin
|
155
157
|
unless ENV["SKIP_FILE_WRITE"]
|
156
|
-
ruby = `ruby -v
|
158
|
+
ruby = `ruby -v`.chomp
|
157
159
|
FileUtils.mkdir_p("tmp")
|
158
160
|
file = File.open("tmp/#{Time.now.iso8601}-#{ruby}-memory-#{TEST_COUNT}-times.txt", 'w')
|
159
161
|
file.sync = true
|
@@ -178,6 +180,11 @@ namespace :perf do
|
|
178
180
|
end
|
179
181
|
end
|
180
182
|
|
183
|
+
task :ram_over_time do
|
184
|
+
Kernel.warn("The ram_over_time task is deprecated. Use mem_over_time")
|
185
|
+
Rake::Task["perf:ram_over_time"].invoke
|
186
|
+
end
|
187
|
+
|
181
188
|
desc "iterations per second"
|
182
189
|
task :ips => [:setup] do
|
183
190
|
require 'benchmark/ips'
|
@@ -248,6 +255,8 @@ namespace :perf do
|
|
248
255
|
num = Integer(ENV["TEST_COUNT"] || 1)
|
249
256
|
opts = {}
|
250
257
|
opts[:ignore_files] = /#{ENV['IGNORE_FILES_REGEXP']}/ if ENV['IGNORE_FILES_REGEXP']
|
258
|
+
opts[:allow_files] = "#{ENV['ALLOW_FILES']}" if ENV['ALLOW_FILES']
|
259
|
+
|
251
260
|
puts "Running #{num} times"
|
252
261
|
report = MemoryProfiler.report(opts) do
|
253
262
|
num.times { call_app }
|
@@ -36,6 +36,12 @@ class TasksTest < ActiveSupport::TestCase
|
|
36
36
|
assert_match 'Server: "webrick"', result
|
37
37
|
end
|
38
38
|
|
39
|
+
test 'authenticate with a custom user' do
|
40
|
+
env = { "AUTH_CUSTOM_USER" => "true", "PATH_TO_HIT" => "authenticated", "USE_AUTH" => "true", "TEST_COUNT" => "2" }
|
41
|
+
result = rake 'perf:test', env: env
|
42
|
+
assert_match 'Auth: true', result
|
43
|
+
end
|
44
|
+
|
39
45
|
test 'test' do
|
40
46
|
rake "perf:test"
|
41
47
|
end
|
@@ -72,11 +78,11 @@ class TasksTest < ActiveSupport::TestCase
|
|
72
78
|
rake "perf:mem"
|
73
79
|
end
|
74
80
|
|
75
|
-
test '
|
76
|
-
rake "perf:
|
81
|
+
test 'mem_over_time' do
|
82
|
+
rake "perf:mem_over_time"
|
77
83
|
end
|
78
84
|
|
79
85
|
test 'ips' do
|
80
|
-
rake "perf:
|
86
|
+
rake "perf:mem_over_time"
|
81
87
|
end
|
82
88
|
end
|
data/test/rails_app/perf.rake
CHANGED
@@ -2,3 +2,7 @@ $LOAD_PATH << File.expand_path("../../../lib", __FILE__)
|
|
2
2
|
|
3
3
|
require 'derailed_benchmarks'
|
4
4
|
require 'derailed_benchmarks/tasks'
|
5
|
+
|
6
|
+
if ENV['AUTH_CUSTOM_USER']
|
7
|
+
DerailedBenchmarks.auth.user = -> { User.first_or_create!(email: "user@example.com", password: 'password') }
|
8
|
+
end
|
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.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Schneeman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: memory_profiler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '10'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: thor
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.19'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.19'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: capybara
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -222,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
236
|
version: '0'
|
223
237
|
requirements: []
|
224
238
|
rubyforge_project:
|
225
|
-
rubygems_version: 2.4.5
|
239
|
+
rubygems_version: 2.4.5.1
|
226
240
|
signing_key:
|
227
241
|
specification_version: 4
|
228
242
|
summary: Benchmarks designed to performance test your ENTIRE site
|