-
-
Notifications
You must be signed in to change notification settings - Fork 102
Conversation
We have 3 rubocop offences
Do we want to change Rubocop I'm trying to fix them at the moment. |
Little bump. I can work on any changes if needed. |
Some refactoring of those methods would be good but happy for the rules to be disabled for those methods temporarily, isn't the rubocop.yml file controlled from the |
You are correct for the |
@benoittgt I'm quite happy for you to update |
I don't know if we still need to keep benchmarks #233 (comment) |
I started fixing offenses. But I still have 171 ! |
I will probably import only benchmarks and speed changes on a new PR. I tried to rebase but it was very painful. |
No worries about RuboCop part @benoittgt, I'm planning to address them in |
Do we still want this? |
I think so if you want to spend the time updating it, a bunch of the old ruby stuff is now irrelevant, and some of the rules will have been improved anyway? |
lib/rspec/support/ruby_features.rb:9:7: C: Outdent access modifiers like module_function. module_function ^^^^^^^^^^^^^^^ lib/rspec/support/ruby_features.rb:24:7: C: Outdent access modifiers like module_function. module_function ^^^^^^^^^^^^^^^ lib/rspec/support/ruby_features.rb:48:7: C: Outdent access modifiers like module_function. module_function ^^^^^^^^^^^^^^^
lib/rspec/support/spec/string_matcher.rb:7:1: C: Extra empty line detected at block body beginning.
The check name is a little misleading. The check really is more: "`returned` called from inside a block". Given RSpec's DSL syntax and our heavy block usage, from which calling `return` is valid, this is being turned off.
lib/rspec/support/caller_filter.rb:72:23: C: Operator *= should be surrounded with a single space. increment *= 2 # The choice of two here is arbitrary. ^^ lib/rspec/support/method_signature_verifier.rb:98:48: C: Operator + should be surrounded with a single space. @max_non_kw_args = @min_non_kw_args + optional_non_kw_args ^
This raises the code metric thresholds for perceived complexity and assignment branch conditionals. These are only meant to be temporary settings to ignore the existing offenses. We fully intend to reduce these over time.
We have not decided how we are going to handle the symbol to proc vs block implementations. This is because the block is faster on Ruby 1.8.7, REE, and JRuby but slower on Ruby 1.9.2 through 2.2.2.
lib/rspec/support/version_checker.rb:8:9: C: Do not use parallel assignment. @library_name, @library_version = library_name, library_version ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
We should be good now. |
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.
I don't know if we still need to keep benchmarks
As long as we use them to justify our styling choices - probably yes.
We can give in and use what rubocop-performance
tells us to, however some express concerns regarding its defaults.
The changes to the code look fine, but what relevance do the benchmarks have? |
Good question. I just looked at commit body benoittgt@6b27ac2
But I should have look deeper. The file no longer exist and also we do not check this rule rspec-support/.rubocop_rspec_base.yml Line 130 in 8ba857e
So I am in favor of removing this benchmark first. For the second benchmark. This is related to a rule we didn't choose yet. benoittgt@6c8f550
|
I guess we can put Style/SymbolProc:
Enabled: false to Symbol to proc makes sense, we can decide/enforce later when we drop Ruby < 2.3. |
I'm happy to keep either benchmark, but a comment at the top explaining that they are there for checking the performance of rubocop/rbhint recommendations |
😱 🏃 🙈 |
script/run_build
Outdated
@@ -20,6 +20,9 @@ fi | |||
|
|||
fold "cukes" run_cukes | |||
|
|||
# To remove after benchmark measurement | |||
ruby benchmarks/symbol_to_proc_vs_block.rb | |||
|
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.
I wouldn't add this to the build personally, whats your thoughts here
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.
I think it take some times to gather benchmark result on each Ruby build. You not get easily info that the new Ruby version is for example slower that the previous one on one benchmark. This is more something that should be inserted in https://rubybench.org/ruby/ruby/releases
Also it will add some time to the build itself. I think we should try to have always a fast CI.
I am not convinced about adding it. 😊
I would prefer a benchmark for each gem (except rspec-rails) that assert rspec gem benchmarking performance using a tool like https://github.com/marketplace/actions/continuous-benchmark (it needs Ruby support).
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.
It might be an idea to run once, but not for every build.
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.
I tried two things:
- Did what Aaron did. Run the benchmark on the CI. But we do not have bare metal server like for https://rubybench.org/hardware. So we cannot have real benchmark. One build can go on a machine that is slower or impacted about installed libraries. I don't think benchmark on CI is a good idea: https://bheisler.github.io/post/benchmarking-in-the-cloud/
- I tried https://github.com/benchmark-driver/benchmark-driver with
bundle exec benchmark-driver -vv --bundler benchmarks/symbol_to_proc_vs_block.rb --rvm '2.2.2;2.3.1;2.4.6;2.5.5;2.6.6;2.7.1'
and:
require 'benchmark_driver'
Benchmark.driver do |x|
x.prelude <<~RUBY
RANGE = (1..100)
def sym_to_proc_with_map
RANGE.map(&:to_s)
end
def sym_to_proc_with_each
RANGE.each(&:to_s)
end
def block_with_map
RANGE.map { |i| i.to_s }
end
def block_with_each
RANGE.each { |i| i.to_s }
end
RUBY
size = 10_000
range = (1..size)
x.report 'Block map', %{ block_with_map }
x.report 'Symbol#to_proc map', %{ sym_to_proc_with_map }
x.report 'Block each', %{ block_with_each }
x.report 'Symbol#to_proc each', %{ sym_to_proc_with_each }
end
But the gem looks pretty buggy at the moment. I was not able to have the output for all ruby with with this command. Also results are not properly compared at the end you have to do it by hand. Plus, it is working only after Ruby 2.2.
Here is a cleaned output https://gist.github.com/benoittgt/3464d476060dbbe1dce5e7c649a3587a
BTW I noticed that the part with benchmark-ips was not written in the initial benchmark by Aaron. So I rewrote it.
I think both benchmark should be removed. I already removed one. If we want to have benchmarks like this one (basic Ruby across Ruby version), we should rely on rubybench.
|
||
puts "\nUsing Array#map size #{size}:" | ||
Benchmark.ips do |x| | ||
x.report('Block ') { range.map { |i| i.to_s } } |
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.
Benchmark is incorrect. It should be:
x.report('Block ') { range.map { |i| i.to_s } } | |
x.report('Block ') { block_with_map } |
This is the same for all the others.
1. The benchmark-ips part is incorrect 2. This benchmark is meant to be tested across different Ruby versions but for that we use the CI. The CI is not isolated enough to be used to run benchmark. 3. Results are difficult to gather The solution is to rely on rubybench.org
…pec/rspec-support#350) Updated rubocop rules see: rspec/rspec-support#350 --- This commit was imported from rspec/rspec-support@0953e54.
I'm trying to reduce the number of open PR on this repo.
This PR is a merge conflict free of #233.