Skip to content
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

Disable Performance/Casecmp cop #31

Merged
merged 1 commit into from
Aug 23, 2017
Merged

Disable Performance/Casecmp cop #31

merged 1 commit into from
Aug 23, 2017

Conversation

onk
Copy link
Owner

@onk onk commented Aug 23, 2017

Comparison with downcase or upcase is an idiom.
Idioms have higher priority than some performance improvement.

1.2x faster is not critical.

require "benchmark/ips"
Benchmark.ips do |x|
  a = "foo"
  b = "Foo"
  x.report("downcase") { a.downcase == b }
  x.report("casecmp")  { a.casecmp(b) }
  x.compare!
end
Warming up --------------------------------------
            downcase   179.127k i/100ms
             casecmp   203.340k i/100ms
Calculating -------------------------------------
            downcase      5.126M (±12.2%) i/s -     25.257M in   5.013800s
             casecmp      6.188M (±17.0%) i/s -     29.891M in   5.010809s

Comparison:
             casecmp:  6187759.2 i/s
            downcase:  5125593.1 i/s - same-ish: difference falls within error

Comparison with downcase or upcase is an idiom.
Idioms have higher priority than some performance improvement.

1.2x faster is not critical.

```ruby
require "benchmark/ips"
Benchmark.ips do |x|
  a = "foo"
  b = "Foo"
  x.report("downcase") { a.downcase == b }
  x.report("casecmp")  { a.casecmp(b) }
  x.compare!
end
```

```
Warming up --------------------------------------
            downcase   179.127k i/100ms
             casecmp   203.340k i/100ms
Calculating -------------------------------------
            downcase      5.126M (±12.2%) i/s -     25.257M in   5.013800s
             casecmp      6.188M (±17.0%) i/s -     29.891M in   5.010809s

Comparison:
             casecmp:  6187759.2 i/s
            downcase:  5125593.1 i/s - same-ish: difference falls within error
```
@onk onk merged commit 97d7227 into master Aug 23, 2017
@onk onk deleted the disable_performance_casecmp branch September 7, 2017 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant