mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 12:34:21 +00:00
Optimized `String#split` with `/ /` (single space regexp) as simple string splitting. [ruby-core:98272] | |compare-ruby|built-ruby| |:--------------|-----------:|---------:| |re_space-1 | 432.786k| 1.539M| | | -| 3.56x| |re_space-10 | 76.231k| 191.547k| | | -| 2.51x| |re_space-100 | 8.152k| 19.557k| | | -| 2.40x| |re_space-1000 | 837.405| 2.022k| | | -| 2.41x| ruby-core:98272: https://bugs.ruby-lang.org/issues/15771#change-85511
19 lines
513 B
YAML
19 lines
513 B
YAML
prelude: |
|
|
str1 = [*0..5].join(" ") + " "
|
|
str10 = str1 * 10
|
|
str100 = str10 * 10
|
|
str1000 = str100 * 10
|
|
benchmark:
|
|
to_chars-1: str1.split('')
|
|
to_chars-10: str10.split('')
|
|
to_chars-100: str100.split('')
|
|
to_chars-1000: str1000.split('')
|
|
to_words-1: str1.split(' ')
|
|
to_words-10: str10.split(' ')
|
|
to_words-100: str100.split(' ')
|
|
to_words-1000: str1000.split(' ')
|
|
re_space-1: str1.split(/ /)
|
|
re_space-10: str10.split(/ /)
|
|
re_space-100: str100.split(/ /)
|
|
re_space-1000: str1000.split(/ /)
|