@@ -985,25 +985,30 @@ Comparison:
985985> This is only useful for cases where you are checking <br >
986986> for a match and not using the resultant match object. <br >
987987> :warning : <br >
988- > ` Regexp#=== ` is also faster than ` String#match ` but you need to switch the order of arguments.
988+ > ` Regexp#=== ` is also faster than ` String#match ` but you need to switch the order of arguments.<br >
989+ > :warning : <br >
990+ > ` String#include? ` This is only useful for cases where you are checking substring inclusion
989991
990992```
991- $ ruby -v code/string/===-vs-=~-vs-match.rb.rb
992- ruby 2.2.2p95 (2015年04月13日 revision 50295 ) [x86_64-darwin14 ]
993+ $ ruby -v code/string/===-vs-=~-vs-match.rb
994+ ruby 2.4.2p198 (2017年09月14日 revision 59899 ) [x86_64-darwin16 ]
993995
996+ Warming up --------------------------------------
997+ String#include? 238.465k i/100ms
998+ String#=~ 161.826k i/100ms
999+ Regexp#=== 147.986k i/100ms
1000+ String#match 136.749k i/100ms
9941001Calculating -------------------------------------
995- String#=~ 98.184k i/100ms
996- Regexp#=== 92.382k i/100ms
997- String#match 83.601k i/100ms
998- -------------------------------------------------
999- String#=~ 2.442M (± 7.6%) i/s - 12.175M
1000- Regexp#=== 2.259M (± 7.9%) i/s - 11.271M
1001- String#match 1.840M (± 7.3%) i/s - 9.196M
1002+ String#include? 5.961M (± 8.5%) i/s - 29.808M in 5.035615s
1003+ String#=~ 2.843M (± 8.1%) i/s - 14.241M in 5.040590s
1004+ Regexp#=== 2.689M (± 7.3%) i/s - 13.467M in 5.032779s
1005+ String#match 2.371M (± 5.2%) i/s - 11.897M in 5.031192s
10021006
10031007Comparison:
1004- String#=~: 2442335.1 i/s
1005- Regexp#===: 2259277.3 i/s - 1.08x slower
1006- String#match: 1839815.4 i/s - 1.33x slower
1008+ String#include?: 5960785.4 i/s
1009+ String#=~: 2843384.2 i/s - 2.10x slower
1010+ Regexp#===: 2689290.6 i/s - 2.22x slower
1011+ String#match: 2370791.0 i/s - 2.51x slower
10071012```
10081013
10091014See [ #59 ] ( https://github.com/JuanitoFatas/fast-ruby/pull/59 ) and [ #62 ] ( https://github.com/JuanitoFatas/fast-ruby/pull/62 ) for discussions.
0 commit comments