gem_bench 2.0.0 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +69 -38
- data/CONTRIBUTING.md +42 -26
- data/LICENSE.txt +1 -1
- data/README.md +315 -66
- data/lib/gem_bench/jersey.rb +150 -0
- data/lib/gem_bench/player.rb +20 -18
- data/lib/gem_bench/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +58 -28
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59e1de2253ef3ec5e1a82ee85837764bd4f5bb52e4e1445489d7ae3d28adf5b6
|
4
|
+
data.tar.gz: '088ee6272de7a10656b202e1a24a29cfc144e0032e218fdb6322552eec416fe5'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98f28036a4f33a517593ed8af78fdf3b177d4033bc58a3e1be55958513ec28e72f24dad753f3c400fa0b35af6b40b85d17026e11fed669862dd2b8d56f7690bc
|
7
|
+
data.tar.gz: e5334f36e3e534be04804c83ee37eb94810b05aa73fefcb1c39b573f3fdab692ea1f4a9ca5b5a929bdc0a2666dcb591520f8648e412fc30ff3c44bc76c5da9bd
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -11,37 +11,68 @@ and this project adheres to [Semantic Versioning v2](https://semver.org/spec/v2.
|
|
11
11
|
### Fixed
|
12
12
|
### Removed
|
13
13
|
|
14
|
+
[2.0.2] SEP.17.2024
|
15
|
+
COVERAGE: 82.15% -- 382/465 lines in 9 files
|
16
|
+
BRANCH COVERAGE: 58.79% -- 97/165 branches in 9 branches
|
17
|
+
51.72% documented
|
18
|
+
### Added
|
19
|
+
- CI for Ancient Rubies
|
20
|
+
- Ruby 2.3
|
21
|
+
- Ruby 2.4
|
22
|
+
- Ruby 2.5
|
23
|
+
- Ruby 2.6
|
24
|
+
- More & improved documentation
|
25
|
+
### Fixed
|
26
|
+
- Typo in URL in documentation
|
27
|
+
- Gemspec description & Summary
|
28
|
+
|
29
|
+
[2.0.1] SEP.17.2024
|
30
|
+
COVERAGE: 82.15% -- 382/465 lines in 9 files
|
31
|
+
BRANCH COVERAGE: 58.08% -- 97/167 branches in 9 files
|
32
|
+
51.72% documented
|
33
|
+
### Added
|
34
|
+
- Ability to re-namespace and load copy of a gem alongside vanilla version for benchmarking via `GemBench::Jersey`
|
35
|
+
- See: https://github.com/panorama-ed/memo_wise/pull/339
|
36
|
+
- Many more tests
|
37
|
+
- `kettle-soup-cover` for test coverage enforcement
|
38
|
+
- Better documentation
|
39
|
+
- Improved instructions for contributing
|
40
|
+
### Changed
|
41
|
+
- Improved `bin/checksums`
|
42
|
+
### Fixed
|
43
|
+
- Stopped swallowing `ArgumentError` in certain exceptional cases
|
44
|
+
|
14
45
|
[2.0.0] SEP.25.2023
|
15
46
|
### Added
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
47
|
+
- Compatible with Bundler 2+
|
48
|
+
- Checksums for release
|
49
|
+
- SHA-256
|
50
|
+
- SHA-512
|
51
|
+
- Signed releases
|
52
|
+
- Add CODE_OF_CONDUCT.md
|
53
|
+
- Add SECURITY.md (Security policy)
|
54
|
+
- Github Actions
|
24
55
|
### Changed
|
25
|
-
|
26
|
-
|
27
|
-
|
56
|
+
- Dropped support for Ruby 2.0, 2.1, and 2.2
|
57
|
+
- `VERSION` constant now lives at `GemBench::Version::VERSION`, enhanced by `version_gem`
|
58
|
+
- Changelog updated to Keep-a-changelog format (going forward)
|
28
59
|
### Removed
|
29
|
-
|
30
|
-
|
60
|
+
- Removed Appraisals
|
61
|
+
- Removed Travis-CI
|
31
62
|
|
32
63
|
[1.0.6] SEP.09.2018
|
33
|
-
|
34
|
-
|
64
|
+
- Documentation improvements
|
65
|
+
- Add Ruby 2.5 to build matrix
|
35
66
|
|
36
67
|
[1.0.5] JUN.05.2017
|
37
|
-
|
68
|
+
- Allow github macro as an alternative to git within Gemfile for strict version constraint analysis
|
38
69
|
|
39
70
|
[1.0.3] JUN.02.2017
|
40
|
-
|
41
|
-
|
71
|
+
- fixed accidental removal of loaded_gems in 1.0.2
|
72
|
+
- better documentation
|
42
73
|
|
43
74
|
[1.0.2] JUN.02.2017
|
44
|
-
|
75
|
+
- version constraint checking, useful to add a spec enforcing Gemfile version constraints, by Peter Boling
|
45
76
|
- Console use:
|
46
77
|
- GemBench::StrictVersionRequirement.new({verbose: true})
|
47
78
|
- Spec use:
|
@@ -55,41 +86,41 @@ end
|
|
55
86
|
```
|
56
87
|
|
57
88
|
[1.0.1] MAR.25.2017
|
58
|
-
|
89
|
+
- fixed a typo that prevented Gemfile comparison by mobilutz
|
59
90
|
|
60
91
|
[1.0.0] FEB.26.2017
|
61
|
-
|
92
|
+
- New feature: scan all code (except for test/spec/feature code) in all loaded gems for a given regex:
|
62
93
|
- puts GemBench.find(look_for_regex: /HERE BE DRAGONS/).starters.map {|gem| "#{gem.name} has DRAGONS at #{gem.stats}" }.join("\n")
|
63
|
-
|
64
|
-
|
65
|
-
|
94
|
+
- Added basic specs
|
95
|
+
- More Documentation
|
96
|
+
- added back git dependency to gemspec (pulled in latest Gem scaffolding from Bundler :/)
|
66
97
|
|
67
98
|
[0.0.8] JAN.16.2014
|
68
|
-
|
69
|
-
|
70
|
-
|
99
|
+
- Corrected issues with 0.0.7 release.
|
100
|
+
- More Documentation
|
101
|
+
- removed git dependency from gemspec
|
71
102
|
|
72
103
|
[0.0.7] DEC.23.2013 (Yanked immediately)
|
73
|
-
|
74
|
-
|
75
|
-
|
104
|
+
- Attempt to fix failure on encoding problem, with a rescue fallback (Issue #1) by Peter Boling
|
105
|
+
- Readme / Documentation improvements by John Bachir
|
106
|
+
- Runtime output improvements by John Bachir
|
76
107
|
|
77
108
|
[0.0.6] AUG.29.2013
|
78
|
-
|
79
|
-
|
109
|
+
- Added license to gemspec by Peter Boling
|
110
|
+
- No longer altering Ruby load path - Let the gem manager do that by Peter Boling
|
80
111
|
|
81
112
|
[0.0.5] AUG.28.2013
|
82
|
-
|
113
|
+
- Encode as UTF-8 prior to comparison by Peter Boling
|
83
114
|
|
84
115
|
[0.0.4] APR.06.2013
|
85
|
-
|
116
|
+
- Expanded exclusion list by Peter Boling
|
86
117
|
|
87
118
|
[0.0.3] APR.06.2013
|
88
|
-
|
119
|
+
- Late night coding needs more coffee by Peter Boling
|
89
120
|
|
90
121
|
[0.0.2] APR.06.2013
|
91
|
-
|
92
|
-
|
122
|
+
- Works against 265 dependency Gemfile by Peter Boling
|
123
|
+
- Added ability to evaluate a Gemfile by Peter Boling
|
93
124
|
|
94
125
|
[0.0.1] APR.05.2013
|
95
|
-
|
126
|
+
- Initial release by Peter Boling
|
data/CONTRIBUTING.md
CHANGED
@@ -1,46 +1,62 @@
|
|
1
1
|
## Contributing
|
2
2
|
|
3
|
-
Bug reports and pull requests are welcome on
|
4
|
-
|
5
|
-
the [code of conduct][conduct].
|
3
|
+
Bug reports and pull requests are welcome on GitHub at [https://github.com/pboling/gem_bench][🚎src-main].
|
4
|
+
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to
|
5
|
+
the [code of conduct][🤝conduct].
|
6
6
|
|
7
7
|
To submit a patch, please fork the project and create a patch with tests. Once you're happy with it send a pull request
|
8
|
-
and post a message to the [gitter chat][🏘chat].
|
8
|
+
and you might also post a message to the [gitter chat][🏘chat].
|
9
9
|
|
10
10
|
## Development
|
11
11
|
|
12
|
-
After checking out the repo, run `bin/setup` to install dependencies.
|
12
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
13
|
+
Then, run `bin/rake` to run the default rake tasks, which include specs.
|
14
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
13
15
|
|
14
16
|
## Release
|
15
17
|
|
16
|
-
|
18
|
+
### One-time, Per-developer, Setup
|
19
|
+
|
20
|
+
**IMPORTANT**: Your public key for signing gems will need to be picked up by the line in the
|
21
|
+
`gemspec` defining the `spec.cert_chain` (check the relevant ENV variables there),
|
22
|
+
in order to sign the new release.
|
23
|
+
See: [RubyGems Security Guide][🔒️rubygems-security-guide]
|
24
|
+
|
25
|
+
### To release a new version:
|
17
26
|
|
18
27
|
1. Run `bin/setup && bin/rake` as a tests, coverage, & linting sanity check
|
19
|
-
2.
|
28
|
+
2. Update the version number in `version.rb`
|
20
29
|
3. Run `bin/setup && bin/rake` again as a secondary check, and to update `Gemfile.lock`
|
21
|
-
4.
|
22
|
-
5.
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
`
|
32
|
-
|
30
|
+
4. Run `git commit -am "🔖 Prepare release v<VERSION>"` to commit the changes
|
31
|
+
5. Run `git push` to trigger the final CI pipeline before release, & merge PRs
|
32
|
+
- NOTE: Remember to [check the build][🧪build]!
|
33
|
+
6. Run `export GIT_TRUNK_BRANCH_NAME="$(git remote show origin | grep 'HEAD branch' | cut -d ' ' -f5)" && echo $GIT_TRUNK_BRANCH_NAME`
|
34
|
+
7. Run `git checkout $GIT_TRUNK_BRANCH_NAME`
|
35
|
+
8. Run `git pull origin $GIT_TRUNK_BRANCH_NAME` to ensure you will release the latest trunk code
|
36
|
+
9. Set `SOURCE_DATE_EPOCH` so `rake build` and `rake release` use same timestamp, and generate same checksums
|
37
|
+
- Run `export SOURCE_DATE_EPOCH=$EPOCHSECONDS && echo $SOURCE_DATE_EPOCH`
|
38
|
+
- If the echo above has no output, then it didn't work.
|
39
|
+
- Note that you'll need the `zsh/datetime` module, if running `zsh`.
|
40
|
+
- In `bash` you can use `date +%s` instead, i.e. `export SOURCE_DATE_EPOCH=$(date +%s) && echo $SOURCE_DATE_EPOCH`
|
41
|
+
10. Run `bundle exec rake build`
|
42
|
+
11. Run `bin/checksums` (more [context][🔒️rubygems-checksums-pr]) to create SHA-256 and SHA-512 checksums
|
43
|
+
- Checksums will be committed automatically by the script, but not pushed
|
44
|
+
12. Run `bundle exec rake release` which will create a git tag for the version,
|
45
|
+
push git commits and tags, and push the `.gem` file to [rubygems.org][💎rubygems]
|
33
46
|
|
34
47
|
## Contributors
|
35
48
|
|
36
|
-
[![Contributors]
|
49
|
+
[![Contributors][🖐contributors-img]][🖐contributors]
|
37
50
|
|
38
|
-
Made with [contributors-img][contrib-rocks].
|
51
|
+
Made with [contributors-img][🖐contrib-rocks].
|
39
52
|
|
53
|
+
[🧪build]: https://github.com/pboling/gem_bench/actions
|
54
|
+
[🤝conduct]: https://github.com/pboling/gem_bench/blob/main/CODE_OF_CONDUCT.md
|
55
|
+
[🖐contrib-rocks]: https://contrib.rocks
|
40
56
|
[🖐contributors]: https://github.com/pboling/gem_bench/graphs/contributors
|
41
|
-
[
|
42
|
-
[
|
43
|
-
[
|
57
|
+
[🖐contributors-img]: https://contrib.rocks/image?repo=pboling/gem_bench
|
58
|
+
[💎rubygems]: https://rubygems.org
|
59
|
+
[🔒️rubygems-security-guide]: https://guides.rubygems.org/security/#building-gems
|
60
|
+
[🔒️rubygems-checksums-pr]: https://github.com/rubygems/guides/pull/325
|
61
|
+
[🚎src-main]: https://github.com/pboling/gem_bench
|
44
62
|
[🏘chat]: https://matrix.to/#/%23pboling_gem_bench:gitter.im
|
45
|
-
[rubygems-security-guide]: https://guides.rubygems.org/security/#building-gems
|
46
|
-
[rubygems]: https://rubygems.org
|
data/LICENSE.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
MIT License
|
2
2
|
|
3
|
-
Copyright (c) 2013 -
|
3
|
+
Copyright (c) 2013 - 2014, 2016 - 2020, 2023 - 2024 Peter H. Boling, http://railsbling.com
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -1,43 +1,175 @@
|
|
1
1
|
# GemBench
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
[🚎
|
28
|
-
[🚎
|
29
|
-
[
|
30
|
-
[
|
31
|
-
[
|
32
|
-
[
|
33
|
-
[
|
34
|
-
[
|
3
|
+
<div id="badges">
|
4
|
+
|
5
|
+
<div align="center">
|
6
|
+
|
7
|
+
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
|
8
|
+
[![Version](https://img.shields.io/gem/v/gem_bench.svg)](https://rubygems.org/gems/gem_bench)
|
9
|
+
[![Downloads Today](https://img.shields.io/gem/rd/gem_bench.svg)](https://github.com/pboling/gem_bench)
|
10
|
+
[![Depfu](https://badges.depfu.com/badges/865e7bb1d0d3eb3ba807fca7344e22d1/overview.svg)](https://depfu.com/github/pboling/gem_bench?project_id=2688)
|
11
|
+
[![CodeCov][🖇codecov-img♻️]][🖇codecov]
|
12
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/80787f126e7a486b19af/test_coverage)](https://codeclimate.com/github/pboling/gem_bench/test_coverage)
|
13
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/80787f126e7a486b19af/maintainability)](https://codeclimate.com/github/pboling/gem_bench/maintainability)
|
14
|
+
[![CI Supported Build][🚎s-wfi]][🚎s-wf]
|
15
|
+
[![CI Unsupported Build][🚎us-wfi]][🚎us-wf]
|
16
|
+
[![CI Style Build][🚎st-wfi]][🚎st-wf]
|
17
|
+
[![CI Coverage Build][🚎cov-wfi]][🚎cov-wf]
|
18
|
+
[![CI Heads Build][🚎hd-wfi]][🚎hd-wf]
|
19
|
+
[![CI Ancient Build][🚎an-wfi]][🚎an-wf]
|
20
|
+
|
21
|
+
[🖇codecov-img♻️]: https://codecov.io/gh/pboling/gem_bench/graph/badge.svg?token=selEoMrZzA
|
22
|
+
[🖇codecov]: https://codecov.io/gh/pboling/gem_bench
|
23
|
+
[🚎s-wf]: https://github.com/pboling/gem_bench/actions/workflows/supported.yml
|
24
|
+
[🚎s-wfi]: https://github.com/pboling/gem_bench/actions/workflows/supported.yml/badge.svg
|
25
|
+
[🚎us-wf]: https://github.com/pboling/gem_bench/actions/workflows/unsupported.yml
|
26
|
+
[🚎us-wfi]: https://github.com/pboling/gem_bench/actions/workflows/unsupported.yml/badge.svg
|
27
|
+
[🚎st-wf]: https://github.com/pboling/gem_bench/actions/workflows/style.yml
|
28
|
+
[🚎st-wfi]: https://github.com/pboling/gem_bench/actions/workflows/style.yml/badge.svg
|
29
|
+
[🚎cov-wf]: https://github.com/pboling/gem_bench/actions/workflows/coverage.yml
|
30
|
+
[🚎cov-wfi]: https://github.com/pboling/gem_bench/actions/workflows/coverage.yml/badge.svg
|
31
|
+
[🚎hd-wf]: https://github.com/pboling/gem_bench/actions/workflows/heads.yml
|
32
|
+
[🚎hd-wfi]: https://github.com/pboling/gem_bench/actions/workflows/heads.yml/badge.svg
|
33
|
+
[🚎an-wf]: https://github.com/pboling/gem_bench/actions/workflows/ancient.yml
|
34
|
+
[🚎an-wfi]: https://github.com/pboling/gem_bench/actions/workflows/ancient.yml/badge.svg
|
35
|
+
|
36
|
+
</div>
|
37
|
+
|
38
|
+
-----
|
39
|
+
|
40
|
+
<div align="center">
|
41
|
+
|
42
|
+
[![Liberapay Patrons][⛳liberapay-img]][⛳liberapay]
|
43
|
+
[![Sponsor Me on Github][🖇sponsor-img]][🖇sponsor]
|
44
|
+
[![Polar Shield][🖇polar-img]][🖇polar]
|
45
|
+
[![Donate to my FLOSS or refugee efforts at ko-fi.com][🖇kofi-img]][🖇kofi]
|
46
|
+
[![Donate to my FLOSS or refugee efforts using Patreon][🖇patreon-img]][🖇patreon]
|
47
|
+
|
48
|
+
[⛳liberapay-img]: https://img.shields.io/liberapay/patrons/pboling.svg?logo=liberapay
|
49
|
+
[⛳liberapay]: https://liberapay.com/pboling/donate
|
50
|
+
[🖇sponsor-img]: https://img.shields.io/badge/Sponsor_Me!-pboling.svg?style=social&logo=github
|
51
|
+
[🖇sponsor]: https://github.com/sponsors/pboling
|
52
|
+
[🖇polar-img]: https://polar.sh/embed/seeks-funding-shield.svg?org=pboling
|
53
|
+
[🖇polar]: https://polar.sh/pboling
|
54
|
+
[🖇kofi-img]: https://img.shields.io/badge/buy%20me%20coffee-donate-yellow.svg
|
55
|
+
[🖇kofi]: https://ko-fi.com/O5O86SNP4
|
56
|
+
[🖇patreon-img]: https://img.shields.io/badge/patreon-donate-yellow.svg
|
57
|
+
[🖇patreon]: https://patreon.com/galtzo
|
58
|
+
|
59
|
+
<span class="badge-buymealatte">
|
60
|
+
<a href="https://www.buymeacoffee.com/pboling"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a latte&emoji=&slug=pboling&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff" /></a>
|
61
|
+
</span>
|
62
|
+
|
63
|
+
</div>
|
64
|
+
</div>
|
65
|
+
|
66
|
+
## What's it do?
|
67
|
+
|
68
|
+
🏁 Copy & Re-namespace any gem to benchmark side-by-side with `benchmarks-ips`!
|
69
|
+
|
70
|
+
👯 For example, many of the ~dozen Memoization gems use the same namespaces (`Memoist`, `Memery`, etc).
|
71
|
+
In order to compare them side-by-side one of them must be re-namespaced.
|
72
|
+
|
73
|
+
<details>
|
74
|
+
<summary>Scene: Spectator at a game of Ruby Sports Gem Ball</summary>
|
75
|
+
|
76
|
+
Gem wearing jersey **#23**:
|
77
|
+
|
78
|
+
> "Put me in coach!"
|
79
|
+
|
80
|
+
Other Gem, also wearing jersey **#23**:
|
81
|
+
|
82
|
+
> "Put me in coach!"
|
83
|
+
|
84
|
+
Coach:
|
85
|
+
|
86
|
+
> ❨╯°□°❩╯︵┻━┻ fine, but one of you change your jersey first!
|
87
|
+
|
88
|
+
</details>
|
89
|
+
|
90
|
+
🤩 Benchmark trunk against released version of a library!
|
91
|
+
|
92
|
+
🧐 A `git clone` build can now be run against the latest public release build, side-by-side, by re-namespacing one of them.
|
93
|
+
|
94
|
+
🕵️♀️ Static Gemfile and installed gem library source code analysis.
|
95
|
+
Regex search through all of a project's source code, including installed Bundler dependencies.
|
96
|
+
|
97
|
+
🛟 Trim down app load times, such as on Heroku, by finding and keeping your worst players on the bench.
|
98
|
+
|
99
|
+
| Project | GemBench |
|
100
|
+
|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
101
|
+
| gem name | [gem_bench](https://rubygems.org/gems/gem_bench) |
|
102
|
+
| code triage | [![Open Source Helpers](https://www.codetriage.com/pboling/gem_bench/badges/users.svg)](https://www.codetriage.com/pboling/gem_bench) |
|
103
|
+
| homepage | [on Github.com][homepage] |
|
104
|
+
| documentation | [on Rdoc.info][documentation] |
|
105
|
+
| live chat | [![Join the chat][🏘chati]][🏘chat] |
|
106
|
+
| expert support | [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/peterboling?utm_source=github&utm_medium=button&utm_term=peterboling&utm_campaign=github) |
|
107
|
+
| `...` 💖 | [![Liberapay Patrons][⛳liberapay-img]][⛳liberapay] [![Sponsor Me][🖇sponsor-img]][🖇sponsor] [![Follow Me on LinkedIn][🖇linkedin-img]][🖇linkedin] [![Find Me on WellFound:][✌️wellfound-img]][✌️wellfound] [![Find Me on CrunchBase][💲crunchbase-img]][💲crunchbase] [![My LinkTree][🌳linktree-img]][🌳linktree] [![Follow Me on Ruby.Social][🐘ruby-mast-img]][🐘ruby-mast] [![Tweet @ Peter][🐦tweet-img]][🐦tweet] [💻][coderme] [🌏][aboutme] |
|
108
|
+
|
35
109
|
[🏘chat]: https://matrix.to/#/%23pboling_gem_bench:gitter.im
|
36
110
|
[🏘chati]: https://badges.gitter.im/Join%20Chat.svg
|
37
111
|
|
112
|
+
<!-- 7️⃣ spread 💖 -->
|
113
|
+
[🐦tweet-img]: https://img.shields.io/twitter/follow/galtzo.svg?style=social&label=Follow%20%40galtzo
|
114
|
+
[🐦tweet]: http://twitter.com/galtzo
|
115
|
+
[🚎blog]: http://www.railsbling.com/tags/gem_bench/
|
116
|
+
[🚎blog-img]: https://img.shields.io/badge/blog-railsbling-brightgreen.svg?style=flat
|
117
|
+
[🖇linkedin]: http://www.linkedin.com/in/peterboling
|
118
|
+
[🖇linkedin-img]: https://img.shields.io/badge/PeterBoling-blue?style=plastic&logo=linkedin
|
119
|
+
[✌️wellfound]: https://angel.co/u/peter-boling
|
120
|
+
[✌️wellfound-img]: https://img.shields.io/badge/peter--boling-orange?style=plastic&logo=wellfound
|
121
|
+
[💲crunchbase]: https://www.crunchbase.com/person/peter-boling
|
122
|
+
[💲crunchbase-img]: https://img.shields.io/badge/peter--boling-purple?style=plastic&logo=crunchbase
|
123
|
+
[🐘ruby-mast]: https://ruby.social/@galtzo
|
124
|
+
[🐘ruby-mast-img]: https://img.shields.io/mastodon/follow/109447111526622197?domain=https%3A%2F%2Fruby.social&style=plastic&logo=mastodon&label=Ruby%20%40galtzo
|
125
|
+
[🌳linktree]: https://linktr.ee/galtzo
|
126
|
+
[🌳linktree-img]: https://img.shields.io/badge/galtzo-purple?style=plastic&logo=linktree
|
127
|
+
|
128
|
+
<!-- Maintainer Contact Links -->
|
129
|
+
[aboutme]: https://about.me/peter.boling
|
130
|
+
[coderme]: https://coderwall.com/Peter%20Boling
|
131
|
+
|
132
|
+
### New for 2.0.1 - `GemBench::Jersey`
|
133
|
+
|
134
|
+
Allows you to re-namespace any gem.
|
135
|
+
You can, for example, benchmark a gem against another version of itself.
|
136
|
+
|
137
|
+
The gem `alt_memery` uses a namespace, `Memery`, that does not match the gem name.
|
138
|
+
|
139
|
+
```ruby
|
140
|
+
require "gem_bench/jersey"
|
141
|
+
|
142
|
+
jersey = GemBench::Jersey.new(
|
143
|
+
gem_name: "alt_memery",
|
144
|
+
trades: {"Memery" => "AltMemery"},
|
145
|
+
metadata: { # optional, mostly used for benchmarking report output
|
146
|
+
something: "a value here",
|
147
|
+
something_else: :obviously,
|
148
|
+
},
|
149
|
+
)
|
150
|
+
jersey.doff_and_don
|
151
|
+
# The re-namespaced constant is now available!
|
152
|
+
AltMemery # => AltMemery
|
153
|
+
jersey.as_klass # => AltMemery
|
154
|
+
|
155
|
+
# The original, unmodified, gem is still there!
|
156
|
+
require "alt_memery"
|
157
|
+
|
158
|
+
Memery # => Memery
|
159
|
+
# So you can use both!
|
160
|
+
```
|
161
|
+
|
162
|
+
NOTE: It is not required by default, so you do need to require the Jersey if you want to use it!
|
163
|
+
|
164
|
+
```ruby
|
165
|
+
require "gem_bench/jersey"
|
166
|
+
```
|
167
|
+
|
168
|
+
For a real example, see: https://github.com/panorama-ed/memo_wise/pull/339
|
169
|
+
|
38
170
|
### New for 2.0.0 - Dropped Support for Ruby 2.0, 2.1, 2.2
|
39
171
|
|
40
|
-
|
172
|
+
- Required Ruby is now 2.3+
|
41
173
|
- `VERSION` is now namespaced at `GemBench::Version::VERSION` and is enhanced by `version_gem`.
|
42
174
|
|
43
175
|
### New for 1.0.2 - Gemfile specs
|
@@ -45,6 +177,7 @@ You: ❨╯°□°❩╯︵┻━┻
|
|
45
177
|
Version constraints are important. Give the Gemfile some love in your CI build
|
46
178
|
|
47
179
|
Create a `spec/gemfile_spec.rb` like:
|
180
|
+
|
48
181
|
```ruby
|
49
182
|
Rspec.describe("Gemfile") do
|
50
183
|
it("has version constraint on every gem") do
|
@@ -76,8 +209,16 @@ For string version constraints anything is allowed (e.g. `'~> 1.0'`), as it assu
|
|
76
209
|
|
77
210
|
Search the Ruby source code of all the gems loaded by your Gemfile for a specified regex, to find out which gems have wat DRAGONS.
|
78
211
|
|
79
|
-
|
80
|
-
|
212
|
+
<details>
|
213
|
+
<summary>Scene: Rubiana Jones is searching for WAT Dragon relics in dusty bins of source code</summary>
|
214
|
+
|
215
|
+
Gem:
|
216
|
+
|
217
|
+
> "I have no wat DRAGONS!"`
|
218
|
+
|
219
|
+
Rubiana Jones:
|
220
|
+
|
221
|
+
> ❨╯°□°❩╯︵┻━┻ Yes you do!
|
81
222
|
|
82
223
|
```
|
83
224
|
>> puts GemBench.find(look_for_regex: /wat/).starters.map {|gem| "#{gem.name} has wat DRAGONS at #{gem.stats}" }.join("\n")
|
@@ -90,6 +231,8 @@ byebug has wat DRAGONS at [["/Users/pboling/.rvm/gems/ruby-2.4.0@foss/gems/byebu
|
|
90
231
|
NOTE: The number (954, above) is not a line number. The file which contains the text `wat` was the 954th file evaluated, i.e. the number doesn't matter.
|
91
232
|
NOTE: This is a contrived example. The occurrence of `wat` in byebug is meaningless: `byebug/commands/frame.rb:34` has ` if there is a front end also watching over things.`. This is just an example! You can find anything you want, perhaps even something important!
|
92
233
|
|
234
|
+
</details>
|
235
|
+
|
93
236
|
It is a fact of RubyGems that many of them do not need to be loaded by your app at boot time.
|
94
237
|
It is a fact of Bundler that you don't know which ones need to be 'required' while staring at the Gemfile.
|
95
238
|
It is a fact of Heroku that you only have 60, 75, or 120 ([by special request](https://devcenter.heroku.com/articles/error-codes#h20-app-boot-timeout)) precious seconds to get your app loaded before ❨╯°□°❩╯︵┻━┻
|
@@ -100,11 +243,22 @@ You can even use it to evaluate your project's actual Gemfile for easy peasy boo
|
|
100
243
|
|
101
244
|
## Installation
|
102
245
|
|
103
|
-
You *may not* need to add this gem to your project.
|
246
|
+
You *may not* need to add this gem to your project.
|
247
|
+
|
248
|
+
Install the gem and add to the application's Gemfile by executing:
|
249
|
+
|
250
|
+
$ bundle add active_security
|
251
|
+
|
252
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
253
|
+
|
254
|
+
$ gem install active_security
|
255
|
+
|
256
|
+
<details>
|
257
|
+
<summary>Installation Options</summary>
|
104
258
|
|
105
259
|
### Option 1
|
106
260
|
|
107
|
-
Just install it, and require it in your`irb
|
261
|
+
Just install it, and require it in your `irb` or `console` session when you want to use it. However, if you load your console with `bundle exec` then you only have access to gems in the gemfile, so either load without `bundle exec` or add it to the `Gemfile`.
|
108
262
|
|
109
263
|
$ gem install gem_bench
|
110
264
|
|
@@ -130,13 +284,16 @@ If you are going to use the gem in your specs, you will need to add it to the te
|
|
130
284
|
|
131
285
|
gem 'gem_bench', :group => :test
|
132
286
|
|
287
|
+
</details>
|
288
|
+
|
133
289
|
## Usage
|
134
290
|
|
135
291
|
Works with Ruby >= 2.3.
|
136
292
|
|
137
|
-
###
|
293
|
+
### Examples
|
138
294
|
|
139
|
-
|
295
|
+
<details>
|
296
|
+
<summary>Getting tired of seeing this `irb` warning, perhaps?</summary>
|
140
297
|
|
141
298
|
```
|
142
299
|
$ bundle exec rails console
|
@@ -145,6 +302,7 @@ irb: warn: can't alias context from irb_context.
|
|
145
302
|
```
|
146
303
|
|
147
304
|
Find out what gems may be causing it by defining `context`!
|
305
|
+
|
148
306
|
```
|
149
307
|
>> require 'gem_bench'
|
150
308
|
=> true
|
@@ -153,13 +311,49 @@ Find out what gems may be causing it by defining `context`!
|
|
153
311
|
[GemBench] Detected 11 loaded gems + 2 loaded gems which GemBench is configured to ignore.
|
154
312
|
=> [byebug, diff-lcs]
|
155
313
|
```
|
314
|
+
|
156
315
|
Then find the file with the first occurrence of the regex in each:
|
316
|
+
|
157
317
|
```
|
158
318
|
>> bad_context_maybes.map { |bcm| bcm.stats.map(&:first) }
|
159
319
|
=> [["/Users/pboling/.rvm/gems/ruby-2.4.0@foss/gems/byebug-9.0.6/lib/byebug/command.rb"], ["/Users/pboling/.rvm/gems/ruby-2.4.0@foss/gems/diff-lcs-1.3/lib/diff/lcs/hunk.rb"]]
|
160
320
|
```
|
161
321
|
|
162
|
-
|
322
|
+
</details>
|
323
|
+
|
324
|
+
<details>
|
325
|
+
<summary>Find what gems have `RAILS_ENV` specific code!</summary>
|
326
|
+
|
327
|
+
Let's try to find what libraries might be using a conditional guard to alter their behavior in a specific Rails environment.
|
328
|
+
|
329
|
+
```
|
330
|
+
# Not a perfect regex, but pretty good: https://rubular.com/r/b7tdIoYOVQM2RR
|
331
|
+
# RAILS_ENV == "development"
|
332
|
+
# Rails.env.development?
|
333
|
+
# Rails.env == "development"
|
334
|
+
# ENV["RAILS_ENV"] == "development"
|
335
|
+
# ENV.fetch("RAILS_ENV") == "development"
|
336
|
+
>> require "gem_bench"
|
337
|
+
=> true
|
338
|
+
>> conditional_rails_behavior_regex = /(ENV(\["|\.fetch\("))?rails(_|\.)env("\]|"\))?( == "|\.)development/i
|
339
|
+
>> conditional_rails_behavior = GemBench.find(look_for_regex: conditional_rails_behavior_regex).starters
|
340
|
+
=> [rack, actionpack, actioncable, actionmailer, rubocop, railties, rubocop-ruby2_7, sass, sass-rails]
|
341
|
+
>> print conditional_rails_behavior.map {|gem| "#{gem.name} has Rails.env condition in #{gem.stats}" }.join("\n")
|
342
|
+
rack has Rails.env condition in [["/Users/pboling/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rack-mini-profiler-3.1.0/lib/mini_profiler_rails/railtie.rb", 1154]]
|
343
|
+
actionpack has Rails.env condition in [["/Users/pboling/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/actionpack-3.2.22.5/lib/action_controller/metal/force_ssl.rb", 1377]]
|
344
|
+
actioncable has Rails.env condition in [["/Users/pboling/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/actioncable-5.2.8.1/lib/action_cable/engine.rb", 886]]
|
345
|
+
actionmailer has Rails.env condition in [["/Users/pboling/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/actionmailer-7.0.5/lib/action_mailer/railtie.rb", 807]]
|
346
|
+
rubocop has Rails.env condition in [["/Users/pboling/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rubocop-ruby2_2-2.0.5/lib/rubocop/ruby2_2/railtie.rb", 131]]
|
347
|
+
railties has Rails.env condition in [["/Users/pboling/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/railties-3.2.22.5/lib/rails.rb", 2478]]
|
348
|
+
rubocop-ruby2_7 has Rails.env condition in [["/Users/pboling/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/rubocop-ruby2_7-2.0.5/lib/rubocop/ruby2_7/railtie.rb", 131]]
|
349
|
+
sass has Rails.env condition in [["/Users/pboling/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/sass-rails-5.1.0/lib/sass/rails/railtie.rb", 3349]]
|
350
|
+
sass-rails has Rails.env condition in [["/Users/pboling/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/sass-rails-5.1.0/lib/sass/rails/railtie.rb", 3349]]
|
351
|
+
```
|
352
|
+
|
353
|
+
</details>
|
354
|
+
|
355
|
+
<details>
|
356
|
+
<summary> Basic Gemfile Analysis</summary>
|
163
357
|
|
164
358
|
Fire up an `irb` session or a `rails console` and then:
|
165
359
|
|
@@ -215,14 +409,17 @@ If you run the check against a real app's Gemfile it will find numerous primary
|
|
215
409
|
|
216
410
|
In a random directory, in an irb session, where there is no Gemfile in sight it will give a lot more information.
|
217
411
|
|
218
|
-
|
412
|
+
</details>
|
413
|
+
|
414
|
+
<details>
|
415
|
+
<summary>Advanced Gemfile Analysis</summary>
|
219
416
|
|
220
417
|
In order to *also* see list gems may *not* be required at boot time you need to:
|
221
418
|
|
222
419
|
1. Make sure you are in the root of a project with a Gemfile
|
223
420
|
2. Make sure the gem is actually a dependency in the Gemfile
|
224
421
|
|
225
|
-
So here's a [
|
422
|
+
So here's a [fat Gemfile][bundle-group-pattern] weighing in at 265 gem dependencies. We'll use it for this example:
|
226
423
|
|
227
424
|
∴ bundle exec rails console
|
228
425
|
Welcome to RAILS. You are using ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin12.2.1]. Have fun ;)
|
@@ -375,52 +572,104 @@ How much faster will my app boot loading 45 fewer gems? A bit.
|
|
375
572
|
|
376
573
|
**Note:** Some of the gems in the list above should have been excluded. They are now excluded as of `gem_bench` version 0.0.4.
|
377
574
|
|
575
|
+
</details>
|
576
|
+
|
378
577
|
## Future
|
379
578
|
|
380
579
|
This gem determines which gems need to be loaded at Rails' boot time by looking for Railties and Engines.
|
381
580
|
A future version will also look for initializers, because gems which have code that runs (e.g. configuration) in an initializer also need to be loaded at boot time.
|
382
581
|
|
383
|
-
##
|
582
|
+
## 🤝 Contributing
|
583
|
+
|
584
|
+
See [CONTRIBUTING.md][🤝contributing]
|
585
|
+
|
586
|
+
[🤝contributing]: CONTRIBUTING.md
|
384
587
|
|
385
|
-
|
588
|
+
### Code Coverage
|
386
589
|
|
387
|
-
|
590
|
+
If you need some ideas of where to help, you could work on adding more code coverage.
|
388
591
|
|
592
|
+
[![Coverage Graph][🔑codecov-g]][🖇codecov]
|
593
|
+
|
594
|
+
[🔑codecov-g]: https://codecov.io/gh/pboling/gem_bench/graphs/tree.svg?token=selEoMrZzA
|
595
|
+
|
596
|
+
## 🌈 Contributors
|
597
|
+
|
598
|
+
[![Contributors][🖐contributors-img]][🖐contributors]
|
599
|
+
|
600
|
+
Made with [contributors-img][🖐contrib-rocks].
|
601
|
+
|
602
|
+
[🖐contrib-rocks]: https://contrib.rocks
|
389
603
|
[🖐contributors]: https://github.com/pboling/gem_bench/graphs/contributors
|
390
|
-
[
|
604
|
+
[🖐contributors-img]: https://contrib.rocks/image?repo=pboling/gem_bench
|
605
|
+
|
606
|
+
## Star History
|
607
|
+
|
608
|
+
<a href="https://star-history.com/#pboling/gem_bench&Date">
|
609
|
+
<picture>
|
610
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=pboling/gem_bench&type=Date&theme=dark" />
|
611
|
+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=pboling/gem_bench&type=Date" />
|
612
|
+
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=pboling/gem_bench&type=Date" />
|
613
|
+
</picture>
|
614
|
+
</a>
|
615
|
+
|
616
|
+
## 🪇 Code of Conduct
|
617
|
+
|
618
|
+
Everyone interacting in this project's codebases, issue trackers,
|
619
|
+
chat rooms and mailing lists is expected to follow the [code of conduct][🪇conduct].
|
620
|
+
|
621
|
+
[🪇conduct]: CODE_OF_CONDUCT.md
|
391
622
|
|
392
|
-
##
|
623
|
+
## 📌 Versioning
|
393
624
|
|
394
|
-
|
625
|
+
This Library adheres to [Semantic Versioning 2.0.0][📌semver].
|
626
|
+
Violations of this scheme should be reported as bugs.
|
627
|
+
Specifically, if a minor or patch version is released that breaks backward compatibility,
|
628
|
+
a new version should be immediately released that restores compatibility.
|
629
|
+
Breaking changes to the public API will only be introduced with new major versions.
|
395
630
|
|
396
|
-
|
631
|
+
To get a better understanding of how SemVer is intended to work over a project's lifetime,
|
632
|
+
read this article from the creator of SemVer:
|
397
633
|
|
398
|
-
|
399
|
-
Violations of this scheme should be reported as bugs. Specifically,
|
400
|
-
if a minor or patch version is released that breaks backward
|
401
|
-
compatibility, a new version should be immediately released that
|
402
|
-
restores compatibility. Breaking changes to the public API will
|
403
|
-
only be introduced with new major versions.
|
634
|
+
- ["Major Version Numbers are Not Sacred"][📌major-versions-not-sacred]
|
404
635
|
|
405
|
-
As a result of this policy, you can (and should) specify a
|
406
|
-
|
636
|
+
As a result of this policy, you can (and should) specify a dependency on these libraries using
|
637
|
+
the [Pessimistic Version Constraint][📌pvc] with two digits of precision.
|
407
638
|
|
408
639
|
For example:
|
409
640
|
|
410
|
-
|
641
|
+
```ruby
|
642
|
+
spec.add_dependency("gem_bench", "~> 2.0")
|
643
|
+
```
|
411
644
|
|
412
|
-
See [CHANGELOG.md]
|
645
|
+
See [CHANGELOG.md][📌changelog] for list of releases.
|
413
646
|
|
414
|
-
|
647
|
+
[comment]: <> ( 📌 VERSIONING LINKS )
|
415
648
|
|
416
|
-
|
417
|
-
|
649
|
+
[📌pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
|
650
|
+
[📌semver]: http://semver.org/
|
651
|
+
[📌major-versions-not-sacred]: https://tom.preston-werner.com/2022/05/23/major-version-numbers-are-not-sacred.html
|
652
|
+
[📌changelog]: CHANGELOG.md
|
653
|
+
|
654
|
+
## 📄 License
|
655
|
+
|
656
|
+
The gem is available as open source under the terms of
|
657
|
+
the [MIT License][📄license] [![License: MIT][📄license-img]][📄license-ref].
|
658
|
+
See [LICENSE.txt][📄license] for the official [Copyright Notice][📄copyright-notice-explainer].
|
659
|
+
|
660
|
+
[comment]: <> ( 📄 LEGAL LINKS )
|
661
|
+
|
662
|
+
[📄copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
|
663
|
+
[📄license]: LICENSE.txt
|
664
|
+
[📄license-ref]: https://opensource.org/licenses/MIT
|
665
|
+
[📄license-img]: https://img.shields.io/badge/License-MIT-green.svg
|
666
|
+
|
667
|
+
### © Copyright
|
668
|
+
|
669
|
+
* Copyright (c) 2013 - 2014, 2016 - 2020, 2023 - 2024 [Peter H. Boling][peterboling] of [Rails Bling][railsbling]
|
418
670
|
|
419
|
-
[semver]: http://semver.org/
|
420
|
-
[pvc]: http://docs.rubygems.org/read/chapter/16#page74
|
421
|
-
[bundle-group-pattern]: https://gist.github.com/pboling/4564780
|
422
671
|
[railsbling]: http://www.railsbling.com
|
423
672
|
[peterboling]: http://www.peterboling.com
|
424
|
-
[
|
673
|
+
[bundle-group-pattern]: https://gist.github.com/pboling/4564780
|
425
674
|
[documentation]: http://rdoc.info/github/pboling/gem_bench/frames
|
426
675
|
[homepage]: https://github.com/pboling/gem_bench
|
@@ -0,0 +1,150 @@
|
|
1
|
+
# Std Libs Dependencies
|
2
|
+
require "tmpdir"
|
3
|
+
|
4
|
+
# Re-write a gem to a temp directory, re-namespace the primary namespace of that gem module, and load it.
|
5
|
+
# If the original gem defines multiple top-level namespaces, they can all be renamed by providing more key value pairs.
|
6
|
+
# If the original gem monkey patches other libraries, that behavior can't be isolated, so YMMV.
|
7
|
+
#
|
8
|
+
# NOTE: Non-top-level namespaces do not need to be renamed, as they are isolated within their parent namespace.
|
9
|
+
#
|
10
|
+
# Usage
|
11
|
+
#
|
12
|
+
# jersey = GemBench::Jersey.new(
|
13
|
+
# gem_name: "alt_memery"
|
14
|
+
# trades: {
|
15
|
+
# "Memery" => "AltMemery"
|
16
|
+
# },
|
17
|
+
# metadata: {
|
18
|
+
# something: "a value here",
|
19
|
+
# something_else: :obviously,
|
20
|
+
# },
|
21
|
+
# )
|
22
|
+
# jersey.doff_and_don
|
23
|
+
# # The re-namespaced constant is now available!
|
24
|
+
# AltMemery # => AltMemery
|
25
|
+
#
|
26
|
+
module GemBench
|
27
|
+
class Jersey
|
28
|
+
attr_reader :gem_name
|
29
|
+
attr_reader :gem_path
|
30
|
+
attr_reader :trades
|
31
|
+
attr_reader :metadata
|
32
|
+
attr_reader :files
|
33
|
+
attr_reader :verbose
|
34
|
+
|
35
|
+
def initialize(gem_name:, trades:, metadata: {}, verbose: false)
|
36
|
+
@gem_name = gem_name
|
37
|
+
@gem_path = Gem.loaded_specs[gem_name]&.full_gem_path
|
38
|
+
@gem_lib_dir = Gem
|
39
|
+
@trades = trades
|
40
|
+
@metadata = metadata
|
41
|
+
@verbose = verbose
|
42
|
+
end
|
43
|
+
|
44
|
+
def required?
|
45
|
+
gem_path && trades.values.all? { |new_namespace| Object.const_defined?(new_namespace) }
|
46
|
+
end
|
47
|
+
|
48
|
+
# Generates tempfiles and requires them, resulting
|
49
|
+
# in a loaded gem that will not have namespace
|
50
|
+
# collisions when alongside the original-namespaced gem.
|
51
|
+
# If a block is provided the contents of each file will be yielded to the block,
|
52
|
+
# after all namespace substitutions are complete, but before the contents
|
53
|
+
# are written to the re-namespaced gem. The return value of the block will be
|
54
|
+
# written to the file in this scenario.
|
55
|
+
#
|
56
|
+
# @return void
|
57
|
+
def doff_and_don(&block)
|
58
|
+
return puts "Skipping #{gem_name} (not loaded on #{RUBY_VERSION})" unless gem_path
|
59
|
+
|
60
|
+
puts "Doffing #{gem_path}" if verbose
|
61
|
+
Dir.mktmpdir do |directory|
|
62
|
+
files = []
|
63
|
+
Dir[File.join(gem_path, "lib", "**", "*.rb")].map do |file|
|
64
|
+
if verbose
|
65
|
+
puts file
|
66
|
+
puts File.basename(file)
|
67
|
+
puts "--------------------------------"
|
68
|
+
end
|
69
|
+
dirname = File.dirname(file)
|
70
|
+
puts "dirname: #{dirname}" if verbose
|
71
|
+
is_at_gem_root = dirname[(-4)..(-1)] == "/lib"
|
72
|
+
puts "is_at_gem_root: #{is_at_gem_root}" if verbose
|
73
|
+
lib_split = dirname.split("/lib/")[-1]
|
74
|
+
puts "lib_split: #{lib_split}" if verbose
|
75
|
+
# lib_split could be like:
|
76
|
+
# - "ruby/gems/3.2.0/gems/method_source-1.1.0/lib"
|
77
|
+
# - "method_source"
|
78
|
+
# Se we check to make sure it is actually a subdir of the gem's lib directory
|
79
|
+
full_path = File.join(gem_path, "lib", lib_split)
|
80
|
+
relative_path = !is_at_gem_root && Dir.exist?(full_path) && lib_split
|
81
|
+
puts "relative_path: #{relative_path}" if verbose
|
82
|
+
filename = File.basename(file)[0..-4]
|
83
|
+
puts "filename: #{filename}" if verbose
|
84
|
+
|
85
|
+
if relative_path
|
86
|
+
dir_path = File.join(directory, relative_path)
|
87
|
+
Dir.mkdir(dir_path) unless Dir.exist?(dir_path)
|
88
|
+
puts "creating #{filename} in #{dir_path}" if verbose
|
89
|
+
files << create_tempfile_copy(file, filename, dir_path, :dd1, &block)
|
90
|
+
else
|
91
|
+
puts "directory not relative (#{directory}) for file #{filename}" if verbose
|
92
|
+
files << create_tempfile_copy(file, filename, directory, :dd2, &block)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
load_gem_copy(files)
|
96
|
+
end
|
97
|
+
|
98
|
+
nil
|
99
|
+
end
|
100
|
+
|
101
|
+
def primary_namespace
|
102
|
+
trades.values.first
|
103
|
+
end
|
104
|
+
|
105
|
+
# Will raise NameError if called before #doff_and_don
|
106
|
+
def as_klass
|
107
|
+
Object.const_get(primary_namespace) if gem_path
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
def load_gem_copy(files)
|
113
|
+
files.each do |filepath|
|
114
|
+
# begin
|
115
|
+
require filepath
|
116
|
+
# rescue LoadError => e
|
117
|
+
# puts file.to_s
|
118
|
+
# puts tempfile.path
|
119
|
+
# puts e.class
|
120
|
+
# puts e.message
|
121
|
+
# end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# @return [String] the file path of the new copy of the original file
|
126
|
+
def create_tempfile_copy(file, filename, directory, from, &block)
|
127
|
+
# Value of block is returned from File.open
|
128
|
+
File.open(File.join(directory, "#{filename}.rb"), "w") do |file_copy|
|
129
|
+
new_jersey(file, file_copy, from, &block)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
# @return [String] the file path of the new copy of the original file
|
134
|
+
def new_jersey(file, file_copy, from)
|
135
|
+
nj = File.read(file)
|
136
|
+
trades.each do |old_namespace, new_namespace|
|
137
|
+
nj.gsub!(old_namespace, new_namespace)
|
138
|
+
end
|
139
|
+
if verbose
|
140
|
+
puts "new_jersey has from: #{from}"
|
141
|
+
puts "new_jersey has file: #{file}"
|
142
|
+
puts "new_jersey file_copy path: #{file_copy.path}"
|
143
|
+
end
|
144
|
+
nj = yield nj if block_given?
|
145
|
+
file_copy.write(nj)
|
146
|
+
file_copy.close
|
147
|
+
file_copy.path
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
data/lib/gem_bench/player.rb
CHANGED
@@ -27,24 +27,7 @@ module GemBench
|
|
27
27
|
# gems got checked, and which had nothing to check
|
28
28
|
@checked = true
|
29
29
|
line_match ||= GemBench::RAILTIE_REGEX
|
30
|
-
scan =
|
31
|
-
false
|
32
|
-
else
|
33
|
-
begin
|
34
|
-
File.read(file_path).encode(
|
35
|
-
"utf-8",
|
36
|
-
invalid: :replace,
|
37
|
-
undef: :replace,
|
38
|
-
replace: "_",
|
39
|
-
) =~ line_match
|
40
|
-
rescue ArgumentError => e
|
41
|
-
if e.message =~ /invalid byte sequence/
|
42
|
-
puts "[GemBench] checking #{file_path} failed due to unparseable file content"
|
43
|
-
false # Assume the likelihood of files with encoding issues that also contain railtie to be low, so: false.
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
30
|
+
scan = !GemBench::DO_NOT_SCAN.include?(name) && check_line(file_path, line_match)
|
48
31
|
stats << [file_path, scan] if scan
|
49
32
|
self.state = if !!scan
|
50
33
|
GemBench::PLAYER_STATES[:starter]
|
@@ -53,6 +36,23 @@ module GemBench
|
|
53
36
|
end
|
54
37
|
end
|
55
38
|
|
39
|
+
def check_line(file_path, line_match)
|
40
|
+
File.read(file_path).encode(
|
41
|
+
"utf-8",
|
42
|
+
invalid: :replace,
|
43
|
+
undef: :replace,
|
44
|
+
replace: "_",
|
45
|
+
) =~ line_match
|
46
|
+
rescue ArgumentError => e
|
47
|
+
if e.message =~ /invalid byte sequence/
|
48
|
+
puts "[GemBench] checking #{file_path} failed due to unparseable file content"
|
49
|
+
false # Assume the likelihood of files with encoding issues that also contain railtie to be low, so: false.
|
50
|
+
else
|
51
|
+
puts "[GemBench] checking #{file_path} failed. Please report a bug to https://github.com/pboling/gembench/issues"
|
52
|
+
raise e
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
56
|
def starter?
|
57
57
|
state == GemBench::PLAYER_STATES[:starter]
|
58
58
|
end
|
@@ -71,6 +71,8 @@ module GemBench
|
|
71
71
|
"gem '#{name}', '~> #{version}'"
|
72
72
|
when :upgrade # when upgrading, and testing gem compatibility you want to try anything newer
|
73
73
|
"gem '#{name}', '>= #{version}'"
|
74
|
+
else
|
75
|
+
raise ArgumentError, "Unknown format for #{self.class.name}#to_s"
|
74
76
|
end
|
75
77
|
end
|
76
78
|
|
data/lib/gem_bench/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem_bench
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Boling
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
KuxrfYrN+9HvMdm+nZ6TypmKftHY3Gj+/uu+g8Icm/zrvTWAEE0mcJOkfrIoNPJb
|
37
37
|
pF8dMA==
|
38
38
|
-----END CERTIFICATE-----
|
39
|
-
date:
|
39
|
+
date: 2024-09-18 00:00:00.000000000 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
@@ -61,7 +61,7 @@ dependencies:
|
|
61
61
|
version: '1.1'
|
62
62
|
- - ">="
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version: 1.1.
|
64
|
+
version: 1.1.4
|
65
65
|
type: :runtime
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -71,49 +71,61 @@ dependencies:
|
|
71
71
|
version: '1.1'
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: 1.1.
|
74
|
+
version: 1.1.4
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
|
-
name:
|
76
|
+
name: yard
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0.9'
|
79
82
|
- - ">="
|
80
83
|
- !ruby/object:Gem::Version
|
81
|
-
version:
|
84
|
+
version: 0.9.34
|
82
85
|
type: :development
|
83
86
|
prerelease: false
|
84
87
|
version_requirements: !ruby/object:Gem::Requirement
|
85
88
|
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0.9'
|
86
92
|
- - ">="
|
87
93
|
- !ruby/object:Gem::Version
|
88
|
-
version:
|
94
|
+
version: 0.9.34
|
89
95
|
- !ruby/object:Gem::Dependency
|
90
|
-
name: yard
|
96
|
+
name: yard-junk
|
91
97
|
requirement: !ruby/object:Gem::Requirement
|
92
98
|
requirements:
|
93
|
-
- - "
|
99
|
+
- - "~>"
|
94
100
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
101
|
+
version: 0.0.10
|
96
102
|
type: :development
|
97
103
|
prerelease: false
|
98
104
|
version_requirements: !ruby/object:Gem::Requirement
|
99
105
|
requirements:
|
100
|
-
- - "
|
106
|
+
- - "~>"
|
101
107
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
108
|
+
version: 0.0.10
|
103
109
|
- !ruby/object:Gem::Dependency
|
104
|
-
name:
|
110
|
+
name: kettle-soup-cover
|
105
111
|
requirement: !ruby/object:Gem::Requirement
|
106
112
|
requirements:
|
113
|
+
- - "~>"
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '1.0'
|
107
116
|
- - ">="
|
108
117
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
118
|
+
version: 1.0.2
|
110
119
|
type: :development
|
111
120
|
prerelease: false
|
112
121
|
version_requirements: !ruby/object:Gem::Requirement
|
113
122
|
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '1.0'
|
114
126
|
- - ">="
|
115
127
|
- !ruby/object:Gem::Version
|
116
|
-
version:
|
128
|
+
version: 1.0.2
|
117
129
|
- !ruby/object:Gem::Dependency
|
118
130
|
name: awesome_print
|
119
131
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,19 +141,19 @@ dependencies:
|
|
129
141
|
- !ruby/object:Gem::Version
|
130
142
|
version: '0'
|
131
143
|
- !ruby/object:Gem::Dependency
|
132
|
-
name:
|
144
|
+
name: method_source
|
133
145
|
requirement: !ruby/object:Gem::Requirement
|
134
146
|
requirements:
|
135
|
-
- - "
|
147
|
+
- - ">="
|
136
148
|
- !ruby/object:Gem::Version
|
137
|
-
version:
|
149
|
+
version: 1.1.0
|
138
150
|
type: :development
|
139
151
|
prerelease: false
|
140
152
|
version_requirements: !ruby/object:Gem::Requirement
|
141
153
|
requirements:
|
142
|
-
- - "
|
154
|
+
- - ">="
|
143
155
|
- !ruby/object:Gem::Version
|
144
|
-
version:
|
156
|
+
version: 1.1.0
|
145
157
|
- !ruby/object:Gem::Dependency
|
146
158
|
name: rake
|
147
159
|
requirement: !ruby/object:Gem::Requirement
|
@@ -246,10 +258,26 @@ dependencies:
|
|
246
258
|
- - ">="
|
247
259
|
- !ruby/object:Gem::Version
|
248
260
|
version: '0'
|
261
|
+
- !ruby/object:Gem::Dependency
|
262
|
+
name: standard
|
263
|
+
requirement: !ruby/object:Gem::Requirement
|
264
|
+
requirements:
|
265
|
+
- - ">="
|
266
|
+
- !ruby/object:Gem::Version
|
267
|
+
version: 1.35.1
|
268
|
+
type: :development
|
269
|
+
prerelease: false
|
270
|
+
version_requirements: !ruby/object:Gem::Requirement
|
271
|
+
requirements:
|
272
|
+
- - ">="
|
273
|
+
- !ruby/object:Gem::Version
|
274
|
+
version: 1.35.1
|
249
275
|
description: |-
|
250
|
-
|
251
|
-
|
252
|
-
|
276
|
+
* Benchmark different versions of same or similar gems
|
277
|
+
* Copy & Re-namespace any gem to benchmark side-by-side with `benchmarks-ips`
|
278
|
+
* Enforce Gemfile version constraints
|
279
|
+
* Regex search across all installed gem's source code to find issues quickly
|
280
|
+
* Trim down app load times by keeping your worst players on the bench (useful for beating Heroku slug load time cutoff)
|
253
281
|
email:
|
254
282
|
- peter.boling@gmail.com
|
255
283
|
executables: []
|
@@ -264,6 +292,7 @@ files:
|
|
264
292
|
- SECURITY.md
|
265
293
|
- lib/gem_bench.rb
|
266
294
|
- lib/gem_bench/gemfile_line_tokenizer.rb
|
295
|
+
- lib/gem_bench/jersey.rb
|
267
296
|
- lib/gem_bench/player.rb
|
268
297
|
- lib/gem_bench/scout.rb
|
269
298
|
- lib/gem_bench/strict_version_gem.rb
|
@@ -275,10 +304,10 @@ licenses:
|
|
275
304
|
- MIT
|
276
305
|
metadata:
|
277
306
|
homepage_uri: https://railsbling.com/tags/gem_bench/
|
278
|
-
source_code_uri: http://github.com/pboling/gem_bench/tree/v2.0.
|
279
|
-
changelog_uri: http://github.com/pboling/gem_bench/blob/v2.0.
|
307
|
+
source_code_uri: http://github.com/pboling/gem_bench/tree/v2.0.2
|
308
|
+
changelog_uri: http://github.com/pboling/gem_bench/blob/v2.0.2/CHANGELOG.md
|
280
309
|
bug_tracker_uri: http://github.com/pboling/gem_bench/issues
|
281
|
-
documentation_uri: https://www.rubydoc.info/gems/gem_bench/2.0.
|
310
|
+
documentation_uri: https://www.rubydoc.info/gems/gem_bench/2.0.2
|
282
311
|
wiki_uri: http://github.com/pboling/gem_bench/wiki
|
283
312
|
funding_uri: https://liberapay.com/pboling
|
284
313
|
rubygems_mfa_required: 'true'
|
@@ -297,8 +326,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
297
326
|
- !ruby/object:Gem::Version
|
298
327
|
version: '0'
|
299
328
|
requirements: []
|
300
|
-
rubygems_version: 3.
|
329
|
+
rubygems_version: 3.5.18
|
301
330
|
signing_key:
|
302
331
|
specification_version: 4
|
303
|
-
summary:
|
332
|
+
summary: Benchmark different versions of same or similar gems & Static Gemfile and
|
333
|
+
installed gem library source code analysis
|
304
334
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|