require_bench 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.pryrc +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +32 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE +7 -0
- data/README.md +185 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/require_bench.rb +59 -0
- data/lib/require_bench/tasks.rb +31 -0
- data/lib/require_bench/version.rb +3 -0
- data/require_bench.gemspec +28 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d5d31fc8fae92d48022a2c8bbcbc69d9fbfc5462bcd571951b49e0a5d86c1025
|
4
|
+
data.tar.gz: 2b5dce4b6cb6aa780674a15124237baf5edb99ae1c23a55b02f87ece7c0b5a84
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8db583c2c81ed6ab939bfd376daf53ebfdbcd216ca1802238afc32ba95288614586822c25f6dd835b5713be7fc1d77a8eed9e32859e834801cfd5b0657f34058
|
7
|
+
data.tar.gz: 55686eb46bd2b35f97ce4d6d0bad839e3804ad918700cdc53d1400a91926e4b22da063602402950d9e04d842dba1baa8c64531b2a40a706a9727ee8cd4b5d41f
|
data/.gitignore
ADDED
data/.pryrc
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
if defined?(PryByebug)
|
2
|
+
Pry.commands.alias_command 'c', 'continue'
|
3
|
+
Pry.commands.alias_command 's', 'step'
|
4
|
+
Pry.commands.alias_command 'n', 'next'
|
5
|
+
Pry.commands.alias_command 'trace', 'backtrace'
|
6
|
+
end
|
7
|
+
|
8
|
+
# Hit Enter to repeat last command
|
9
|
+
Pry::Commands.command /^$/, "repeat last command" do
|
10
|
+
_pry_.run_command Pry.history.to_a.last
|
11
|
+
end
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.3.4
|
data/.travis.yml
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
---
|
2
|
+
env:
|
3
|
+
global:
|
4
|
+
- JRUBY_OPTS="-Xcli.debug=true --debug"
|
5
|
+
- CC_TEST_REPORTER_ID=5a499d33adfcdac3088a2c917f4b374987d69bf18c1124542cb77ce2db85d8f9
|
6
|
+
|
7
|
+
before_script:
|
8
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
9
|
+
- chmod +x ./cc-test-reporter
|
10
|
+
- ./cc-test-reporter before-build
|
11
|
+
|
12
|
+
script:
|
13
|
+
- bundle exec rspec
|
14
|
+
|
15
|
+
after_script:
|
16
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
17
|
+
|
18
|
+
before_install:
|
19
|
+
- gem update --system
|
20
|
+
- gem install bundler -v 1.16.5
|
21
|
+
|
22
|
+
install:
|
23
|
+
- bundle install
|
24
|
+
|
25
|
+
bundler_args: --no-deployment --jobs 3 --retry 3
|
26
|
+
|
27
|
+
cache: bundler
|
28
|
+
|
29
|
+
language: ruby
|
30
|
+
sudo: false
|
31
|
+
rvm:
|
32
|
+
- 2.5.1
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at peter.boling@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright 2018 Peter Boling of railsbling.com
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,185 @@
|
|
1
|
+
# RequireBench
|
2
|
+
|
3
|
+
Have a Ruby project that has stopped loading, and you aren't sure where the issue is?
|
4
|
+
|
5
|
+
Knowing the last file that was successfully "required" by Ruby can be helpful in diagnosing the issue. This gem will help you find that last required file. It can also help you see where expensive (slow) processing is occurring, by adding `Benchmark.realtime` to every require, and printing the result for every file.
|
6
|
+
|
7
|
+
This is an extraction of a debugging tool that I have copy/pasted into many projects over the years, and it is now time to set it free.
|
8
|
+
|
9
|
+
| Project | RequireBench |
|
10
|
+
|------------------------ | ----------------------- |
|
11
|
+
| gem name | [require_bench](https://rubygems.org/gems/require_bench) |
|
12
|
+
| license | [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) |
|
13
|
+
| download rank | [![Downloads Today](https://img.shields.io/gem/rd/require_bench.svg)](https://github.com/pboling/require_bench) |
|
14
|
+
| version | [![Version](https://img.shields.io/gem/v/require_bench.svg)](https://rubygems.org/gems/require_bench) |
|
15
|
+
| dependencies | [![Depfu](https://badges.depfu.com/badges/272ce0df3bc6df5cbea9354e2c3b65af/count.svg)](https://depfu.com/github/pboling/require_bench?project_id=5614) |
|
16
|
+
| continuous integration | [![Build Status](https://travis-ci.org/pboling/require_bench.svg?branch=master)](https://travis-ci.org/pboling/require_bench) |
|
17
|
+
| test coverage | [![Test Coverage](https://api.codeclimate.com/v1/badges/18523205c207a2b53045/test_coverage)](https://codeclimate.com/github/pboling/require_bench/test_coverage) |
|
18
|
+
| maintainability | [![Maintainability](https://api.codeclimate.com/v1/badges/18523205c207a2b53045/maintainability)](https://codeclimate.com/github/pboling/require_bench/maintainability) |
|
19
|
+
| code triage | [![Open Source Helpers](https://www.codetriage.com/pboling/require_bench/badges/users.svg)](https://www.codetriage.com/pboling/require_bench) |
|
20
|
+
| homepage | [on Github.com][homepage], [on Railsbling.com][blogpage] |
|
21
|
+
| documentation | [on RDoc.info][documentation] |
|
22
|
+
| Spread ~♡ⓛⓞⓥⓔ♡~ | [🌍 🌎 🌏](https://about.me/peter.boling), [🍚](https://www.crowdrise.com/helprefugeeswithhopefortomorrowliberia/fundraiser/peterboling), [➕](https://plus.google.com/+PeterBoling/posts), [👼](https://angel.co/peter-boling), [🐛](https://www.topcoder.com/members/pboling/), [:shipit:](http://coderwall.com/pboling), [![Tweet Peter](https://img.shields.io/twitter/follow/galtzo.svg?style=social&label=Follow)](http://twitter.com/galtzo) |
|
23
|
+
|
24
|
+
## Installation
|
25
|
+
|
26
|
+
Add this line to your application's Gemfile:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
gem 'require_bench'
|
30
|
+
```
|
31
|
+
|
32
|
+
And then execute:
|
33
|
+
|
34
|
+
$ bundle
|
35
|
+
|
36
|
+
Or install it yourself as:
|
37
|
+
|
38
|
+
$ gem install require_bench
|
39
|
+
|
40
|
+
## Usage
|
41
|
+
|
42
|
+
Require the library where it will be loaded prior to any other requires you want to benchmark.
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
require 'require_bench'
|
46
|
+
```
|
47
|
+
|
48
|
+
By default this gem does **nothing**, hacks **nothing**, and has **zero** effects.
|
49
|
+
|
50
|
+
### Turn on benchmarking & output
|
51
|
+
|
52
|
+
Add an environment variable, however you normally do such things, so that in Ruby:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
ENV['REQUIRE_BENCH'] == 'true'
|
56
|
+
```
|
57
|
+
|
58
|
+
Any value other than `'true'` means RubyBench is still turned off.
|
59
|
+
|
60
|
+
### Handy Rake Task for Rails:
|
61
|
+
|
62
|
+
Require in Rakefile, as follows:
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
require 'bundler/setup'
|
66
|
+
require 'require_bench/tasks' # Near the top, just below require 'bundler/setup'!
|
67
|
+
```
|
68
|
+
|
69
|
+
This will ensure it will load before other stuff.
|
70
|
+
|
71
|
+
When running from command line, you will see output as the Rails app boots.
|
72
|
+
```bash
|
73
|
+
∴ REQUIRE_BENCH=true bundle exec rake require_bench:hello
|
74
|
+
[RequireBench] 12.179703 /path/to/my_app/config/application
|
75
|
+
[RequireBench] 0.001726 resque/tasks
|
76
|
+
[RequireBench] 0.000917 resque/scheduler/tasks
|
77
|
+
[RequireBench] 0.000011 rake
|
78
|
+
[RequireBench] 0.000014 active_record
|
79
|
+
[RequireBench] 0.008673 sprockets/rails/task
|
80
|
+
[RequireBench] 0.000012 dynamoid
|
81
|
+
[RequireBench] 0.000004 dynamoid/tasks/database
|
82
|
+
[RequireBench] 0.000012 raven/integrations/tasks
|
83
|
+
[RequireBench] 0.003107 rspec/core/rake_task
|
84
|
+
[RequireBench] 0.000017 csv
|
85
|
+
[RequireBench] 0.000012 resque/tasks
|
86
|
+
[RequireBench] 0.000007 resque/scheduler/tasks
|
87
|
+
[RequireBench] 0.064950 rails/tasks
|
88
|
+
[RequireBench] 0.003305 rake/testtask
|
89
|
+
[RequireBench] 0.001886 rubocop/rake_task
|
90
|
+
[RequireBench] 0.000012 hubspot-ruby
|
91
|
+
[RequireBench] 2.291259 /path/to/my_app/config/environment.rb
|
92
|
+
|
93
|
+
[RequireBench] Slowest Loads by Library, in order
|
94
|
+
1. 11.914224 /path/to/my_app/config/application
|
95
|
+
2. 2.153282 /path/to/my_app/config/environment.rb
|
96
|
+
3. 0.061008 rails
|
97
|
+
4. 0.010827 sprockets
|
98
|
+
5. 0.003179 rspec
|
99
|
+
6. 0.003144 rake
|
100
|
+
7. 0.003127 resque
|
101
|
+
8. 0.001543 rubocop
|
102
|
+
9. 0.000021 dynamoid
|
103
|
+
10. 0.000016 csv
|
104
|
+
11. 0.000016 active_record
|
105
|
+
12. 0.000010 raven
|
106
|
+
13. 0.000005 hubspot-ruby
|
107
|
+
==========
|
108
|
+
14.150402 TOTAL
|
109
|
+
```
|
110
|
+
|
111
|
+
### Output Options
|
112
|
+
|
113
|
+
If the output is too noisy from deep libraries you can add a regex to skip benchmarking of files that match.
|
114
|
+
|
115
|
+
If the value is set in the shell, it should be a string. RequireBench will split the string by comma, Regexp escape each value, and join together with pipe (`|`) to form the regex pattern.
|
116
|
+
|
117
|
+
```bash
|
118
|
+
export REQUIRE_BENCH_SKIP_PATTERN=activesupport,rspec
|
119
|
+
```
|
120
|
+
|
121
|
+
If the `ENV['REQUIRE_BENCH_SKIP_PATTERN']` value is set in Ruby, it can be one of:
|
122
|
+
* a string, to be split by comma, each Regexp escaped, then joined by pipe (`|`)
|
123
|
+
* an array of strings, each to be Regexp escaped, then joined by pipe (`|`)
|
124
|
+
* a Regexp object, which will be used as is.
|
125
|
+
|
126
|
+
```ruby
|
127
|
+
ENV['REQUIRE_BENCH_SKIP_PATTERN'] = 'activesupport,rspec'
|
128
|
+
# or
|
129
|
+
ENV['REQUIRE_BENCH_SKIP_PATTERN'] = [ 'activesupport', 'rspec' ]
|
130
|
+
# or
|
131
|
+
ENV['REQUIRE_BENCH_SKIP_PATTERN'] = Regexp.new('activesupport|rspec')
|
132
|
+
```
|
133
|
+
|
134
|
+
Any file being required that matches the pattern will use the standard, rather than the benchmarked, require.
|
135
|
+
|
136
|
+
#### Fully qualified paths
|
137
|
+
|
138
|
+
Fully qualified paths, or any portion thereof, are fine, because the strings are always Regexp escaped.
|
139
|
+
|
140
|
+
## Development
|
141
|
+
|
142
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
143
|
+
|
144
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
145
|
+
|
146
|
+
## Contributing
|
147
|
+
|
148
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/pboling/require_bench.
|
149
|
+
|
150
|
+
## Code of Conduct
|
151
|
+
|
152
|
+
Everyone interacting in the AnonymousActiveRecord project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/pboling/require_bench/blob/master/CODE_OF_CONDUCT.md).
|
153
|
+
|
154
|
+
## Versioning
|
155
|
+
|
156
|
+
This library aims to adhere to [Semantic Versioning 2.0.0][semver].
|
157
|
+
Violations of this scheme should be reported as bugs. Specifically,
|
158
|
+
if a minor or patch version is released that breaks backward
|
159
|
+
compatibility, a new version should be immediately released that
|
160
|
+
restores compatibility. Breaking changes to the public API will
|
161
|
+
only be introduced with new major versions.
|
162
|
+
|
163
|
+
As a result of this policy, you can (and should) specify a
|
164
|
+
dependency on this gem using the [Pessimistic Version Constraint][pvc] with two digits of precision.
|
165
|
+
|
166
|
+
For example:
|
167
|
+
|
168
|
+
```ruby
|
169
|
+
spec.add_dependency 'require_bench', '~> 0.0'
|
170
|
+
```
|
171
|
+
|
172
|
+
## License
|
173
|
+
|
174
|
+
* Copyright (c) 2018 [Peter H. Boling][peterboling] of [Rails Bling][railsbling]
|
175
|
+
|
176
|
+
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
|
177
|
+
|
178
|
+
[license]: LICENSE
|
179
|
+
[semver]: http://semver.org/
|
180
|
+
[pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
|
181
|
+
[railsbling]: http://www.railsbling.com
|
182
|
+
[peterboling]: http://www.peterboling.com
|
183
|
+
[documentation]: http://rdoc.info/github/pboling/require_bench/frames
|
184
|
+
[homepage]: https://github.com/pboling/require_bench/
|
185
|
+
[blogpage]: http://www.railsbling.com/tags/require_bench/
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "require_bench"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# STD Libs
|
2
|
+
require 'benchmark'
|
3
|
+
|
4
|
+
# This Gem
|
5
|
+
require "require_bench/version"
|
6
|
+
|
7
|
+
module RequireBench
|
8
|
+
TIMINGS = Hash.new { |h, k| h[k] = 0.0 }
|
9
|
+
|
10
|
+
if ENV['REQUIRE_BENCH'] == 'true'
|
11
|
+
def require_with_timing(file)
|
12
|
+
$require_bench_semaphore = true
|
13
|
+
ret = nil
|
14
|
+
seconds = Benchmark.realtime { ret = Kernel.send(:require_without_timing, file) }
|
15
|
+
printf("[RequireBench] %10f %s\n", seconds, file)
|
16
|
+
path_parts = file.split('/')
|
17
|
+
prefix = path_parts.first
|
18
|
+
# requires that were fully qualified paths probably need to be identified
|
19
|
+
# by the full path
|
20
|
+
prefix = file if prefix.nil? || prefix.empty?
|
21
|
+
RequireBench::TIMINGS[prefix] += seconds
|
22
|
+
ret
|
23
|
+
ensure
|
24
|
+
$require_bench_semaphore = nil
|
25
|
+
end
|
26
|
+
module_function :require_with_timing
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
if ENV['REQUIRE_BENCH'] == 'true'
|
31
|
+
skips = ENV['REQUIRE_BENCH_SKIP_PATTERN']
|
32
|
+
if skips
|
33
|
+
skip_pattern = case skips
|
34
|
+
when Regexp then
|
35
|
+
skips
|
36
|
+
when Array then
|
37
|
+
Regexp.new(skips.map{ |x| Regexp.escape(x) }.join('|'))
|
38
|
+
when String then
|
39
|
+
Regexp.new(skips.split(',').map{ |x| Regexp.escape(x) }.join('|'))
|
40
|
+
end
|
41
|
+
puts "[RequireBench] Setting REQUIRE_BENCH_SKIP_PATTERN to #{skip_pattern}"
|
42
|
+
ENV['REQUIRE_BENCH_SKIP_PATTERN'] = skip_pattern
|
43
|
+
end
|
44
|
+
# A Kernel hack that adds require timing to find require problems in app.
|
45
|
+
module Kernel
|
46
|
+
alias require_without_timing require
|
47
|
+
|
48
|
+
def require(file)
|
49
|
+
file = file.to_s
|
50
|
+
|
51
|
+
# Global $ variable, which is always truthy while inside the hack, is to
|
52
|
+
# prevent a scenario that might result in infinite recursion.
|
53
|
+
return require_without_timing(file) if $require_bench_semaphore
|
54
|
+
return require_without_timing(file) if ENV['REQUIRE_BENCH_SKIP_PATTERN'] && file =~ ENV['REQUIRE_BENCH_SKIP_PATTERN']
|
55
|
+
|
56
|
+
RequireBench.require_with_timing(file)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# NOTE: Gem is only active if REQUIRE_BENCH=true is set in shell
|
2
|
+
|
3
|
+
# require 'require_bench/tasks'
|
4
|
+
# will give you the require_bench tasks.
|
5
|
+
# Do it as early as possible during bootstrapping!
|
6
|
+
require 'require_bench'
|
7
|
+
|
8
|
+
namespace :require_bench do
|
9
|
+
desc 'Print timings while booting app, determine slowest loading files'
|
10
|
+
task hello: :environment do
|
11
|
+
tot = 0.0
|
12
|
+
vals = RequireBench::TIMINGS.to_a
|
13
|
+
vals.sort_by! { |a| a[1] }.reverse!
|
14
|
+
if !vals.empty?
|
15
|
+
puts "\n[RequireBench] Slowest Loads by Library, in order"
|
16
|
+
vals.each_with_index do |a, index|
|
17
|
+
tot += a[1]
|
18
|
+
printf("%2d. %10f %s\n", index + 1, a[1], a[0])
|
19
|
+
end
|
20
|
+
puts '=========='
|
21
|
+
printf("%10f %s\n", tot, 'TOTAL')
|
22
|
+
else
|
23
|
+
puts %[
|
24
|
+
require_bench did not track any requires, because it was required too late.
|
25
|
+
Require in Rakefile, as follows
|
26
|
+
require 'bundler/setup'
|
27
|
+
require 'require_bench/tasks'
|
28
|
+
]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "require_bench/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "require_bench"
|
8
|
+
spec.version = RequireBench::VERSION
|
9
|
+
spec.authors = ["Peter Boling"]
|
10
|
+
spec.email = ["peter.boling@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Discover bootstrapping issues in Ruby by benchmarking "Kernel.require"}
|
13
|
+
spec.description = %q{Ruby app loading slowly, or never? Discover bootstrapping issues in Ruby by benchmarking "Kernel.require"}
|
14
|
+
spec.homepage = "https://github.com/pboling/require_bench"
|
15
|
+
|
16
|
+
# Specify which files should be added to the gem when it is released.
|
17
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
18
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
19
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
end
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: require_bench
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Peter Boling
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-09-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Ruby app loading slowly, or never? Discover bootstrapping issues in Ruby
|
56
|
+
by benchmarking "Kernel.require"
|
57
|
+
email:
|
58
|
+
- peter.boling@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".pryrc"
|
65
|
+
- ".rspec"
|
66
|
+
- ".rubocop.yml"
|
67
|
+
- ".ruby-version"
|
68
|
+
- ".travis.yml"
|
69
|
+
- CODE_OF_CONDUCT.md
|
70
|
+
- Gemfile
|
71
|
+
- LICENSE
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- bin/console
|
75
|
+
- bin/setup
|
76
|
+
- lib/require_bench.rb
|
77
|
+
- lib/require_bench/tasks.rb
|
78
|
+
- lib/require_bench/version.rb
|
79
|
+
- require_bench.gemspec
|
80
|
+
homepage: https://github.com/pboling/require_bench
|
81
|
+
licenses: []
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 2.7.6
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: Discover bootstrapping issues in Ruby by benchmarking "Kernel.require"
|
103
|
+
test_files: []
|