-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Benchmark revamp + run benchmark as part of CI #3176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+100
−2,095
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f09c7b1
Organize benchmark gems in a group
stefannibrasil a109a55
Reorganize benchmark scripts
stefannibrasil 07769e9
Strict permissions for gh workflows
stefannibrasil 8714ae3
Skip eval and avoid generating all generators inside of the benchmark…
stefannibrasil 7745001
This was a one-time experiment
stefannibrasil 766c36c
Don't need to keep this around anymore after comparing YML vs JSON
stefannibrasil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| name: Bench | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| pull_request: | ||
| branches: [ main ] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| name: Benchmarks | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: ruby/setup-ruby@v1 | ||
| with: | ||
| ruby-version: '3.4' | ||
| - name: Install dependencies | ||
| run: bundle install | ||
|
|
||
| - name: Generators | ||
| run: RUBYOPT="-W0" bundle exec ruby benchmark/generators.rb | ||
| - name: Require | ||
| run: RUBYOPT="-W0" bundle exec ruby benchmark/require.rb | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
stefannibrasil marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| require 'benchmark/ips' | ||
| require 'faker' | ||
|
|
||
| def generators | ||
| constants.flat_map do |klass| | ||
| subclass_methods(klass) | ||
| end | ||
| end | ||
|
|
||
| def constants | ||
| Faker.constants.delete_if do |subclass| | ||
| %i[ | ||
| Base | ||
| Cat | ||
| Char | ||
| Base58 | ||
| Config | ||
| Date | ||
| Deprecator | ||
| Dog | ||
| Religion | ||
| Time | ||
| VERSION | ||
| ].include?(subclass) | ||
| end.sort | ||
| end | ||
|
|
||
| def subclass_methods(subclass) | ||
| klass = Faker.const_get(subclass) | ||
|
|
||
| public_methods = klass.public_methods(false) - Faker::Base.public_methods(false) | ||
|
|
||
| public_methods.sort.map do |method| | ||
| [klass, method] | ||
| end | ||
| end | ||
thdaraujo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| all_generators = generators | ||
|
|
||
| Benchmark.ips do |x| | ||
| x.report("Number of generators: #{all_generators.count}") do | ||
| all_generators.each { |klass, generator| klass.send(generator) } | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require 'benchmark' | ||
|
|
||
| ms = Benchmark.realtime do | ||
| require 'faker' | ||
| end * 1000 | ||
|
|
||
| puts "took #{ms}ms to load" |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. I also added an extra permission for pull requests, and for the tests workflow as well in 07769e9