derailed_benchmarks 1.7.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +75 -0
  3. data/.github/workflows/check_changelog.yml +11 -8
  4. data/CHANGELOG.md +24 -1
  5. data/README.md +73 -11
  6. data/derailed_benchmarks.gemspec +6 -5
  7. data/gemfiles/rails_5_1.gemfile +3 -1
  8. data/gemfiles/rails_5_2.gemfile +3 -3
  9. data/gemfiles/rails_6_1.gemfile +13 -0
  10. data/gemfiles/rails_git.gemfile +2 -2
  11. data/lib/derailed_benchmarks.rb +4 -2
  12. data/lib/derailed_benchmarks/core_ext/kernel_require.rb +20 -9
  13. data/lib/derailed_benchmarks/git/commit.rb +36 -0
  14. data/lib/derailed_benchmarks/git/in_path.rb +59 -0
  15. data/lib/derailed_benchmarks/git/switch_project.rb +128 -0
  16. data/lib/derailed_benchmarks/git_switch_project.rb +1 -0
  17. data/lib/derailed_benchmarks/load_tasks.rb +1 -1
  18. data/lib/derailed_benchmarks/require_tree.rb +11 -1
  19. data/lib/derailed_benchmarks/{stats_in_file.rb → stats_for_file.rb} +8 -2
  20. data/lib/derailed_benchmarks/stats_from_dir.rb +40 -21
  21. data/lib/derailed_benchmarks/tasks.rb +63 -66
  22. data/lib/derailed_benchmarks/version.rb +1 -1
  23. data/test/derailed_benchmarks/core_ext/kernel_require_test.rb +70 -11
  24. data/test/derailed_benchmarks/git_switch_project_test.rb +83 -0
  25. data/test/derailed_benchmarks/require_tree_test.rb +1 -1
  26. data/test/derailed_benchmarks/stats_from_dir_test.rb +29 -12
  27. data/test/derailed_test.rb +15 -0
  28. data/test/fixtures/require/autoload_child.rb +5 -0
  29. data/test/fixtures/require/autoload_parent.rb +8 -0
  30. data/test/fixtures/require/child_one.rb +1 -1
  31. data/test/fixtures/require/child_two.rb +1 -1
  32. data/test/fixtures/require/load_child.rb +3 -0
  33. data/test/fixtures/require/load_parent.rb +5 -0
  34. data/test/fixtures/require/parent_one.rb +1 -1
  35. data/test/integration/tasks_test.rb +36 -6
  36. data/test/rails_app/config/storage.yml +0 -0
  37. data/test/test_helper.rb +6 -1
  38. metadata +67 -37
  39. data/.travis.yml +0 -18
  40. data/Appraisals +0 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 843a6c3b99ee45120c15af62a592e9bbecb2d88f0917fa292faf9f7128ab721a
4
- data.tar.gz: f1cdfb9c4145c27a8dac7f2c868077c6359213c3c367f2cf8a0f8909f50c9468
3
+ metadata.gz: 9519f087d4eeae220039bb6d4566757d627655ac96789809608b9a93af642b1d
4
+ data.tar.gz: a3f52d5df02db7a7c94043abe86cdf8d2f2bfad72595d36410ac55fc6b036faa
5
5
  SHA512:
6
- metadata.gz: 1936293cd836af98e6af454a7482534c7481b938f4944813a5261a04a9b766b0a169b866397b3d9745d25316cd8916df3b74fc1fd4f1ff46f6e5753eba92bd96
7
- data.tar.gz: 7de041007e174314699cac83eef5b70626e5447eddd705190d68d74cc7d50c0b9d660d032127cf747ea67566a096bbca4aafa05774c413da6f4ca802c8da2c08
6
+ metadata.gz: 817dd67a37109e785bd8c87bdc12235c41bf8de4fa7803cf241aee6c285fcf760290e52598534498a798efd3e1b0505dd39e2124413b8c65be8b6223a6b01439
7
+ data.tar.gz: 0c2aeeffa9460fd920ac28945ce081cd8134397999586cc0c4e508833d9bbd93d5924c2438439fc5445ee403c345ab1149406f67fc0c468e598c44562ffd0127
@@ -0,0 +1,75 @@
1
+ version: 2.1
2
+ orbs:
3
+ ruby: circleci/ruby@1.1.2
4
+ references:
5
+ run_tests: &run_tests
6
+ run:
7
+ name: Run test suite
8
+ command: bundle exec rake test
9
+ # Needed because tests execute raw git commands
10
+ set_git_config: &set_git_config
11
+ run:
12
+ name: Set Git config
13
+ command: git config --global user.email "you@example.com"; git config --global user.name "Your Name"
14
+ restore: &restore
15
+ restore_cache:
16
+ keys:
17
+ - v1_bundler_deps-{{ .Environment.CIRCLE_JOB }}
18
+ save: &save
19
+ save_cache:
20
+ paths:
21
+ - ./vendor/bundle
22
+ key: v1_bundler_deps-{{ .Environment.CIRCLE_JOB }} # CIRCLE_JOB e.g. "ruby-2.5"
23
+ bundle: &bundle
24
+ run:
25
+ name: install dependencies
26
+ command: |
27
+ echo "export BUNDLE_JOBS=4" >> $BASH_ENV
28
+ echo "export BUNDLE_RETRY=3" >> $BASH_ENV
29
+ echo "export BUNDLE_PATH=$(pwd)/vendor/bundle" >> $BASH_ENV
30
+ echo "export BUNDLE_GEMFILE=$(pwd)/gemfiles/$GEMFILE_NAME" >> $BASH_ENV
31
+ source $BASH_ENV
32
+
33
+ bundle install
34
+ bundle update
35
+ bundle clean
36
+ mysteps: &mysteps
37
+ steps:
38
+ - checkout
39
+ - <<: *set_git_config
40
+ - <<: *restore
41
+ - <<: *bundle
42
+ - <<: *run_tests
43
+ - <<: *save
44
+
45
+ jobs:
46
+ test:
47
+ parameters:
48
+ ruby_version:
49
+ type: string
50
+ gemfile:
51
+ type: string
52
+ docker:
53
+ - image: "ruby:<< parameters.ruby_version >>"
54
+ environment:
55
+ GEMFILE_NAME: <<parameters.gemfile>>
56
+ steps:
57
+ - checkout
58
+ - <<: *set_git_config
59
+ - <<: *restore
60
+ - <<: *bundle
61
+ - <<: *run_tests
62
+ - <<: *save
63
+
64
+ workflows:
65
+ all-tests:
66
+ jobs:
67
+ - test:
68
+ matrix:
69
+ parameters:
70
+ ruby_version: ["2.5.8", "2.7.2", "3.0.0"]
71
+ gemfile: ["rails_5_2.gemfile", "rails_6_1.gemfile", "rails_git.gemfile"]
72
+ exclude:
73
+ - ruby_version: "3.0.0"
74
+ gemfile: rails_5_2.gemfile
75
+ name: test-ruby-<<matrix.ruby_version>>-<<matrix.gemfile>>
@@ -1,10 +1,13 @@
1
1
  name: Check Changelog
2
- on: [pull_request]
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, reopened, edited, synchronize]
3
6
  jobs:
4
- build:
5
- runs-on: ubuntu-latest
6
- steps:
7
- - uses: actions/checkout@v1
8
- - name: Check that CHANGELOG is touched
9
- run: |
10
- cat $GITHUB_EVENT_PATH | jq .pull_request.title | grep -i '\[\(\(changelog skip\)\|\(ci skip\)\)\]' || git diff remotes/origin/${{ github.base_ref }} --name-only | grep CHANGELOG.md
7
+ build:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/checkout@v1
11
+ - name: Check that CHANGELOG is touched
12
+ run: |
13
+ cat $GITHUB_EVENT_PATH | jq .pull_request.title | grep -i '\[\(\(changelog skip\)\|\(ci skip\)\)\]' || git diff remotes/origin/${{ github.base_ref }} --name-only | grep CHANGELOG.md
data/CHANGELOG.md CHANGED
@@ -1,4 +1,27 @@
1
- ## master (unreleased)
1
+ ## HEAD
2
+
3
+ ## 2.1.0
4
+
5
+ - Add `perf:heap_diff` tool (https://github.com/schneems/derailed_benchmarks/pull/193)
6
+
7
+ ## 2.0.1
8
+
9
+ - `rack-test` dependency added (https://github.com/schneems/derailed_benchmarks/pull/187)
10
+
11
+ ## 2.0.0
12
+
13
+ - Syntax errors easier to debug with `dead_end` gem (https://github.com/schneems/derailed_benchmarks/pull/182)
14
+ - Minimum ruby version is now 2.5 (https://github.com/schneems/derailed_benchmarks/pull/183)
15
+ - Histograms are now printed side-by-side (https://github.com/schneems/derailed_benchmarks/pull/179)
16
+
17
+ ## 1.8.1
18
+
19
+ - Derailed now tracks memory use from `load` in addition to `require` (https://github.com/schneems/derailed_benchmarks/pull/178)
20
+ - Correct logging of unsuccessful curl requests to file (https://github.com/schneems/derailed_benchmarks/pull/172)
21
+
22
+ ## 1.8.0
23
+
24
+ - Ruby 2.2 is now officialy supported and tested (https://github.com/schneems/derailed_benchmarks/pull/177)
2
25
 
3
26
  ## 1.7.0
4
27
 
data/README.md CHANGED
@@ -9,16 +9,13 @@ A series of things you can use to benchmark a Rails or Ruby app.
9
9
 
10
10
  ## Compatibility/Requirements
11
11
 
12
- This gem has been tested and is known to work with Rails 3.2+ using Ruby
13
- 2.1+. Some commands __may__ work on older versions of Ruby, but not all commands are supported.
14
-
15
12
  For some benchmarks, not all, you'll need to verify you have a working version of curl on your OS:
16
13
 
17
14
  ```
18
15
  $ which curl
19
16
  /usr/bin/curl
20
17
  $ curl -V
21
- curl 7.37.1 #...
18
+ curl 7.64.1 #...
22
19
  ```
23
20
 
24
21
  ## Install
@@ -201,12 +198,17 @@ You can run commands against your app by running `$ derailed exec`. There are se
201
198
  ```
202
199
  $ bundle exec derailed exec --help
203
200
  $ derailed exec perf:allocated_objects # outputs allocated object diff after app is called TEST_COUNT times
201
+ $ derailed exec perf:app # runs the performance test against two most recent commits of the current app
204
202
  $ derailed exec perf:gc # outputs GC::Profiler.report data while app is called TEST_COUNT times
203
+ $ derailed exec perf:heap # heap analyzer
205
204
  $ derailed exec perf:ips # iterations per second
205
+ $ derailed exec perf:library # runs the same test against two different branches for statistical comparison
206
206
  $ derailed exec perf:mem # show memory usage caused by invoking require per gem
207
- $ derailed exec perf:objects # profiles ruby allocation
208
207
  $ derailed exec perf:mem_over_time # outputs memory usage over time
208
+ $ derailed exec perf:objects # profiles ruby allocation
209
+ $ derailed exec perf:stackprof # stackprof
209
210
  $ derailed exec perf:test # hits the url TEST_COUNT times
211
+ $ derailed exec perf:heap_diff # three heaps generation for comparison
210
212
  ```
211
213
 
212
214
  Instead of going over each command we'll look at common problems and which commands are best used to diagnose them. Later on we'll cover all of the environment variables you can use to configure derailed benchmarks in it's own section.
@@ -274,7 +276,7 @@ This is similar to `$ bundle exec derailed bundle:objects` however it includes o
274
276
 
275
277
  ## I want a Heap Dump
276
278
 
277
- If you're still struggling with runtime memory you can generate a heap dump that can later be analyzed using [heap_inspect](https://github.com/schneems/heapy).
279
+ If you're still struggling with runtime memory you can generate a heap dump that can later be analyzed using [heapy](https://github.com/schneems/heapy).
278
280
 
279
281
  ```
280
282
  $ bundle exec derailed exec perf:heap
@@ -298,6 +300,40 @@ For more help on getting data from a heap dump see
298
300
  $ heapy --help
299
301
  ```
300
302
 
303
+ ### I want more heap dumps
304
+
305
+ When searching for a leak, you can use heap dumps for comparison to see what is
306
+ retained. See [SamSaffron's slides](https://speakerdeck.com/samsaffron/why-ruby-2-dot-1-excites-me?slide=27)
307
+ (or [a more recent inspired blog post](https://blog.skylight.io/hunting-for-leaks-in-ruby/))
308
+ for a clear example. You can generate 3 dumps (one every `TEST_COUNT` calls) using the
309
+ next command:
310
+
311
+ ```
312
+ $ bundle exec derailed exec perf:heap
313
+ Endpoint: "/"
314
+ Running 1000 times
315
+ Heap file generated: "tmp/2021-05-06T15:19:26+02:00-heap-0.ndjson"
316
+ Running 1000 times
317
+ Heap file generated: "tmp/2021-05-06T15:19:26+02:00-heap-1.ndjson"
318
+ Running 1000 times
319
+ Heap file generated: "tmp/2021-05-06T15:19:26+02:00-heap-2.ndjson"
320
+
321
+ Diff
322
+ ====
323
+ Retained STRING 90 objects of size 4790/91280 (in bytes) at: /Users/ulysse/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/utils.rb:461
324
+ Retained ICLASS 20 objects of size 800/91280 (in bytes) at: /Users/ulysse/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/sinatra-contrib-2.0.8.1/lib/sinatra/namespace.rb:198
325
+ Retained DATA 20 objects of size 1360/91280 (in bytes) at: /Users/ulysse/.rbenv/versions/2.7.2/lib/ruby/2.7.0/monitor.rb:238
326
+ Retained STRING 20 objects of size 800/91280 (in bytes) at: /Users/ulysse/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rack-protection-2.0.8.1/lib/rack/protection/xss_header.rb:20
327
+ Retained STRING 10 objects of size 880/91280 (in bytes) at: /Users/ulysse/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/newrelic_rpm-5.4.0.347/lib/new_relic/agent/transaction.rb:890
328
+ Retained CLASS 10 objects of size 4640/91280 (in bytes) at: /Users/ulysse/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/sinatra-contrib-2.0.8.1/lib/sinatra/namespace.rb:198
329
+ Retained IMEMO 10 objects of size 480/91280 (in bytes) at: /Users/ulysse/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1017
330
+ ...
331
+
332
+ Run `$ heapy --help` for more options
333
+
334
+ Also read https://speakerdeck.com/samsaffron/why-ruby-2-dot-1-excites-me?slide=27 to understand better what you are reading.
335
+ ```
336
+
301
337
  ### Memory Is large at boot.
302
338
 
303
339
  Ruby memory typically goes in one direction, up. If your memory is large when you boot the application it will likely only increase. In addition to debugging memory retained from dependencies obtained while running `$ derailed bundle:mem` you'll likely want to see how your own files contribute to memory use.
@@ -448,11 +484,37 @@ When the test is done it will output which commit "won" and by how much:
448
484
  ```
449
485
  ❤️ ❤️ ❤️ (Statistically Significant) ❤️ ❤️ ❤️
450
486
 
451
- [7b4d80cb37] "1.8x Faster Partial Caching - Faster Cache Keys" - (10.9711965 seconds)
452
- FASTER by:
453
- 1.0870x [older/newer]
454
- 8.0026% [(older - newer) / older * 100]
455
- [13d6aa3a7b] "Merge pull request #36284 from kamipo/fix_eager_loading_with_string_joins" - (11.9255485 seconds)
487
+ [f1ab117] (11.3844 seconds) "I am the new commit" ref: "winner"
488
+ FASTER 🚀🚀🚀 by:
489
+ 1.0062x [older/newer]
490
+ 0.6147% [(older - newer) / older * 100]
491
+ [5594a2d] (11.4548 seconds) "Old commit" ref: "loser"
492
+
493
+ Iterations per sample:
494
+ Samples: 100
495
+
496
+ Test type: Kolmogorov Smirnov
497
+ Confidence level: 99.0 %
498
+ Is significant? (max > critical): true
499
+ D critical: 0.2145966026289347
500
+ D max: 0.26
501
+
502
+ Histograms (time ranges are in seconds):
503
+
504
+ [f1ab117] description: [5594a2d] description:
505
+ "I am the new commit" "Old commit"
506
+ ┌ ┐ ┌ ┐
507
+ [11.2 , 11.28) ┤▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 12 [11.2 , 11.28) ┤▇▇▇▇ 3
508
+ [11.28, 11.36) ┤▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 22 [11.28, 11.36) ┤▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 19
509
+ [11.35, 11.43) ┤▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 30 [11.35, 11.43) ┤▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 17
510
+ [11.43, 11.51) ┤▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 17 [11.43, 11.51) ┤▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 25
511
+ [11.5 , 11.58) ┤▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 13 [11.5 , 11.58) ┤▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 15
512
+ [11.58, 11.66) ┤▇▇▇▇▇▇▇ 6 [11.58, 11.66) ┤▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 13
513
+ [11.65, 11.73) ┤ 0 [11.65, 11.73) ┤▇▇▇▇ 3
514
+ [11.73, 11.81) ┤ 0 [11.73, 11.81) ┤▇▇▇▇ 3
515
+ [11.8 , 11.88) ┤ 0 [11.8 , 11.88) ┤▇▇▇ 2
516
+ └ ┘ └ ┘
517
+ # of runs in range # of runs in range
456
518
  ```
457
519
 
458
520
  You can provide this to the Rails team along with the example app you used to benchmark (so they can independently verify if needed).
@@ -20,22 +20,23 @@ Gem::Specification.new do |gem|
20
20
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
21
21
  gem.require_paths = ["lib"]
22
22
 
23
- gem.required_ruby_version = ">= 2.1.0"
23
+ gem.required_ruby_version = ">= 2.5.0"
24
24
 
25
25
  gem.add_dependency "heapy", "~> 0"
26
- gem.add_dependency "memory_profiler", "~> 0"
26
+ gem.add_dependency "memory_profiler", ">= 0", "< 2"
27
27
  gem.add_dependency "get_process_mem", "~> 0"
28
28
  gem.add_dependency "benchmark-ips", "~> 2"
29
29
  gem.add_dependency "rack", ">= 1"
30
30
  gem.add_dependency "rake", "> 10", "< 14"
31
31
  gem.add_dependency "thor", ">= 0.19", "< 2"
32
32
  gem.add_dependency "ruby-statistics", ">= 2.1"
33
- gem.add_dependency "unicode_plot", ">= 0.0.4", "< 1.0.0"
34
- gem.add_dependency "mini_histogram", "~> 0"
33
+ gem.add_dependency "mini_histogram", ">= 0.3.0"
34
+ gem.add_dependency "dead_end", ">= 0"
35
+ gem.add_dependency "rack-test", ">= 0"
35
36
 
37
+ gem.add_development_dependency "webrick", ">= 0"
36
38
  gem.add_development_dependency "capybara", "~> 2"
37
39
  gem.add_development_dependency "m"
38
40
  gem.add_development_dependency "rails", "> 3", "<= 7"
39
41
  gem.add_development_dependency "devise", "> 3", "< 6"
40
- gem.add_development_dependency "appraisal", "2.2.0"
41
42
  end
@@ -1,10 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # BUNDLE_GEMFILE="gemfiles/rails_5_1.gemfile" bundle exec m test/integration/tasks_test.rb:30
4
+ #
3
5
  # This file was generated by Appraisal
4
6
 
5
7
  source "https://rubygems.org"
6
8
 
7
- gem "rails", "~> 5.1.0"
9
+ gem "rails", "~> 5.1.7"
8
10
 
9
11
  group :development, :test do
10
12
  gem "sqlite3", platform: [:ruby, :mswin, :mingw]
@@ -1,10 +1,10 @@
1
- # frozen_string_literal: true
2
-
3
1
  # This file was generated by Appraisal
2
+ #
3
+ # BUNDLE_GEMFILE="gemfiles/rails_5_2.gemfile" bundle exec m test/integration/tasks_test.rb:30
4
4
 
5
5
  source "https://rubygems.org"
6
6
 
7
- gem "rails", "~> 5.2.0"
7
+ gem "rails", "~> 5.2.4.4"
8
8
 
9
9
  group :development, :test do
10
10
  gem "sqlite3", platform: [:ruby, :mswin, :mingw]
@@ -0,0 +1,13 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 6.1.1"
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: "../"
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # $ BUNDLE_GEMFILE="$(pwd)/gemfiles/rails_git.gemfile" bundle exec m test/integration/tasks_test.rb:30
3
+ # $ BUNDLE_GEMFILE="$(pwd)/gemfiles/rails_git.gemfile" bundle exec m test/integration/tasks_test.rb:50
4
4
 
5
5
  source "https://rubygems.org"
6
6
 
7
- gem "rails", github: "rails/rails", ref: "3054e1d584e7eca110c69a1f8423f2e0866abbf9"
7
+ gem "rails", github: "rails/rails", ref: "12bb9d32f56883914abcd98fd72e3c68c444808d"
8
8
 
9
9
  gem 'devise', github: "plataformatec/devise"
10
10
 
@@ -2,9 +2,10 @@
2
2
 
3
3
  require 'time'
4
4
  require 'bundler'
5
-
6
5
  require 'get_process_mem'
7
6
 
7
+ require 'dead_end'
8
+
8
9
  module DerailedBenchmarks
9
10
  def self.gem_is_bundled?(name)
10
11
  specs = ::Bundler.locked_gems.specs.each_with_object({}) {|spec, hash| hash[spec.name] = spec }
@@ -43,8 +44,9 @@ end
43
44
  require 'derailed_benchmarks/require_tree'
44
45
  require 'derailed_benchmarks/auth_helper'
45
46
 
46
- require 'derailed_benchmarks/stats_in_file'
47
+ require 'derailed_benchmarks/stats_for_file'
47
48
  require 'derailed_benchmarks/stats_from_dir'
49
+ require 'derailed_benchmarks/git/switch_project'
48
50
 
49
51
  if DerailedBenchmarks.gem_is_bundled?("devise")
50
52
  DerailedBenchmarks.auth = DerailedBenchmarks::AuthHelpers::Devise.new
@@ -17,12 +17,16 @@ module Kernel
17
17
 
18
18
  alias_method :original_require, :require
19
19
  alias_method :original_require_relative, :require_relative
20
+ alias_method(:original_load, :load)
21
+
22
+ def load(file, wrap = false)
23
+ measure_memory_impact(file) do |file|
24
+ original_load(file)
25
+ end
26
+ end
20
27
 
21
28
  def require(file)
22
29
  measure_memory_impact(file) do |file|
23
- # "source_annotation_extractor" is deprecated in Rails 6
24
- # # if we don't skip the library it leads to a crash
25
- # next if file == "rails/source_annotation_extractor" && Rails.version >= '6.0'
26
30
  original_require(file)
27
31
  end
28
32
  end
@@ -67,22 +71,29 @@ module Kernel
67
71
  end
68
72
  end
69
73
 
70
- # Top level node that will store all require information for the entire app
71
- TOP_REQUIRE = DerailedBenchmarks::RequireTree.new("TOP")
72
- REQUIRE_STACK.push(TOP_REQUIRE)
73
74
 
75
+ # I honestly have no idea why this Object delegation is needed
76
+ # I keep staring at bootsnap and it doesn't have to do this
77
+ # is there a bug in their implementation they haven't caught or
78
+ # am I doing something different?
74
79
  class Object
75
80
  private
81
+ def load(path, wrap = false)
82
+ Kernel.load(path, wrap)
83
+ end
76
84
 
77
85
  def require(path)
78
86
  Kernel.require(path)
79
87
  end
80
88
  end
81
89
 
82
- # Don't forget to assign a cost to the top level
83
- cost_before_requiring_anything = GetProcessMem.new.mb
84
- TOP_REQUIRE.cost = cost_before_requiring_anything
90
+ # Top level node that will store all require information for the entire app
91
+ TOP_REQUIRE = DerailedBenchmarks::RequireTree.new("TOP")
92
+ REQUIRE_STACK.push(TOP_REQUIRE)
93
+ TOP_REQUIRE.cost = GetProcessMem.new.mb
94
+
85
95
  def TOP_REQUIRE.print_sorted_children(*args)
86
96
  self.cost = GetProcessMem.new.mb - self.cost
87
97
  super
88
98
  end
99
+
@@ -0,0 +1,36 @@
1
+ module DerailedBenchmarks
2
+ # Represents a specific commit in a git repo
3
+ #
4
+ # Can be used to get information from the commit or to check it out
5
+ #
6
+ # commit = GitCommit.new(path: "path/to/repo", ref: "6e642963acec0ff64af51bd6fba8db3c4176ed6e")
7
+ # commit.short_sha # => "6e64296"
8
+ # commit.checkout! # Will check out the current commit at the repo in the path
9
+ class Git::Commit
10
+ attr_reader :ref, :description, :time, :short_sha, :log
11
+
12
+ def initialize(path: , ref: , log_dir: Pathname.new("/dev/null"))
13
+ @in_git_path = Git::InPath.new(path)
14
+ @ref = ref
15
+ @log = log_dir.join("#{file_safe_ref}.bench.txt")
16
+
17
+ Dir.chdir(path) do
18
+ checkout!
19
+ @description = @in_git_path.description
20
+ @short_sha = @in_git_path.short_sha
21
+ @time = @in_git_path.time
22
+ end
23
+ end
24
+
25
+ alias :desc :description
26
+ alias :file :log
27
+
28
+ def checkout!
29
+ @in_git_path.checkout!(ref)
30
+ end
31
+
32
+ private def file_safe_ref
33
+ ref.gsub('/', ':')
34
+ end
35
+ end
36
+ end