[#98645] [Ruby master Misc#16933] DevelopersMeeting20200618Japan — mame@...

Issue #16933 has been reported by mame (Yusuke Endoh).

14 messages 2020/06/04

[#98663] [Ruby master Bug#16936] `make check TESTS="-n !/Foo#method/"` not skipping the test case — jaruga@...

Issue #16936 has been reported by jaruga (Jun Aruga).

13 messages 2020/06/05

[#98772] [Ruby master Bug#16959] Weakmap has specs and third-party usage despite being a private API — headius@...

Issue #16959 has been reported by headius (Charles Nutter).

13 messages 2020/06/12

[#98826] [Ruby master Feature#16963] Remove English.rb from Ruby 2.8/3.0 — hsbt@...

Issue #16963 has been reported by hsbt (Hiroshi SHIBATA).

9 messages 2020/06/16

[#98920] [Ruby master Bug#16978] Ruby should not use realpath for __FILE__ — v.ondruch@...

Issue #16978 has been reported by vo.x (Vit Ondruch).

24 messages 2020/06/23

[#98947] [Ruby master Feature#16986] Anonymous Struct literal — ko1@...

Issue #16986 has been reported by ko1 (Koichi Sasada).

66 messages 2020/06/26

[#98964] [Ruby master Feature#16989] Sets: need ♥️ — marcandre-ruby-core@...

Issue #16989 has been reported by marcandre (Marc-Andre Lafortune).

33 messages 2020/06/26

[#98965] [Ruby master Feature#16990] Sets: operators compatibility with Array — marcandre-ruby-core@...

Issue #16990 has been reported by marcandre (Marc-Andre Lafortune).

11 messages 2020/06/26

[#98968] [Ruby master Feature#16993] Sets: from hash keys using Hash#key_set — marcandre-ruby-core@...

Issue #16993 has been reported by marcandre (Marc-Andre Lafortune).

10 messages 2020/06/26

[#98997] [Ruby master Feature#17000] 2.7.2 turns off deprecation warnings by deafult — mame@...

Issue #17000 has been reported by mame (Yusuke Endoh).

16 messages 2020/06/30

[ruby-core:98669] [Ruby master Feature#13750] Improve String#casecmp? and Symbol#casecmp? performance with ASCII string

From: akshaybirajdar05@...
Date: 2020-06-07 17:15:12 UTC
List: ruby-core #98669
Issue #13750 has been updated by the_spectator (Akshay Birajdar).


@koic Made a new attempt with patch https://github.com/ruby/ruby/pull/2941

----------------------------------------
Feature #13750: Improve String#casecmp? and Symbol#casecmp? performance with ASCII string
https://bugs.ruby-lang.org/issues/13750#change-86015

* Author: watson1978 (Shizuo Fujita)
* Status: Open
* Priority: Normal
----------------------------------------
I think String#casecmp and String#casecmp? are similar methods.
But they have different performance on ASCII string.

Seems that String#casecmp handles ASCII string only,
however it is faster than String#casecmp?.

This patch will use the code of String#casecmp with ASCII string on String#casecmp?.
But, this patch will introduce a few penalties for UTF8 string in where detect ASCII/UTF8 string.

~~~
String#casecmp? ASCII -> 61.3 % up
String#casecmp? UTF8  ->  1.3 % down
Symbol#casecmp? ASCII -> 80.0 % up
Symbol#casecmp? UTF8  ->  4.0 % down
~~~

### Before
~~~
Calculating -------------------------------------
      String#casecmp      5.961M (3.8%) i/s -     29.838M in   5.017907s
String#casecmp? ASCII
                          3.530M (ア 8.6%) i/s -     17.554M in   5.034848s
String#casecmp? UTF8      1.252M (ア 7.4%) i/s -      6.213M in   5.012168s
      Symbol#casecmp      8.555M (ア 2.4%) i/s -     42.822M in   5.009280s
Symbol#casecmp? ASCII
                          4.235M (ア 9.7%) i/s -     20.824M in   5.001368s
Symbol#casecmp? UTF8      1.329M (ア 0.1%) i/s -      6.704M in   5.043725s
~~~

### After
~~~
Calculating -------------------------------------
      String#casecmp      5.984M (ア 6.4%) i/s -     29.829M in   5.020331s
String#casecmp? ASCII
                          5.658M (ア 1.5%) i/s -     28.308M in   5.004547s
String#casecmp? UTF8      1.215M (ア 4.3%) i/s -      6.132M in   5.060292s
      Symbol#casecmp      8.651M (ア 0.9%) i/s -     43.313M in   5.007215s
Symbol#casecmp? ASCII
                          7.462M (ア 0.5%) i/s -     37.489M in   5.023892s
Symbol#casecmp? UTF8      1.275M (ア 0.2%) i/s -      6.444M in   5.052743s
~~~


### Test code
~~~ruby
require 'benchmark/ips'

Benchmark.ips do |x|
  x.report "String#casecmp" do |loop|
    loop.times { "aBcDeF".casecmp("abcdefg") }
  end
  x.report "String#casecmp? ASCII" do |loop|
    loop.times { "aBcDeF".casecmp?("abcdefg") }
  end
  x.report "String#casecmp? UTF8" do |loop|
    loop.times { "\u{e4 f6 fc}".casecmp?("\u{c4 d6 dc}") }
  end

  x.report "Symbol#casecmp" do |loop|
    loop.times { :aBcDeF.casecmp(:abcdefg) }
  end
  x.report "Symbol#casecmp? ASCII" do |loop|
    loop.times { :aBcDeF.casecmp?(:abcdefg) }
  end
  x.report "Symbol#casecmp? UTF8" do |loop|
    loop.times { :"\u{e4 f6 fc}".casecmp?(:"\u{c4 d6 dc}") }
  end
end
~~~

### Patch
https://github.com/ruby/ruby/pull/1668



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next