1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Added more benchmarks for String

This commit is contained in:
Nobuyoshi Nakada 2020-02-29 15:41:36 +09:00
parent f5b7896921
commit 5e897227ff
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
5 changed files with 76 additions and 0 deletions

View file

@ -0,0 +1,26 @@
prelude: |
lstr1 = [*"a".."z",*"0".."9"].join("")
lstr10 = lstr1 * 10
lstr100 = lstr10 * 10
lstr1000 = lstr100 * 10
lnonascii1 = [*"\u{e0}".."\u{ff}"].join("")
lnonascii10 = lnonascii1 * 10
lnonascii100 = lnonascii10 * 10
lnonascii1000 = lnonascii100 * 10
ustr1 = [*"A".."Z",*"0".."9"].join("")
ustr10 = ustr1 * 10
ustr100 = ustr10 * 10
ustr1000 = ustr100 * 10
unonascii1 = [*"\u{c0}".."\u{df}"].join("")
unonascii10 = unonascii1 * 10
unonascii100 = unonascii10 * 10
unonascii1000 = unonascii100 * 10
benchmark:
casecmp-1: lstr1.casecmp(ustr1)
casecmp-10: lstr10.casecmp(ustr10)
casecmp-100: lstr100.casecmp(ustr100)
casecmp-1000: lstr1000.casecmp(ustr1000)
casecmp-nonascii1: lnonascii1.casecmp(unonascii1)
casecmp-nonascii10: lnonascii10.casecmp(unonascii10)
casecmp-nonascii100: lnonascii100.casecmp(unonascii100)
casecmp-nonascii1000: lnonascii1000.casecmp(unonascii1000)

View file

@ -0,0 +1,26 @@
prelude: |
lstr1 = [*"a".."z",*"0".."9"].join("")
lstr10 = lstr1 * 10
lstr100 = lstr10 * 10
lstr1000 = lstr100 * 10
lnonascii1 = [*"\u{e0}".."\u{ff}"].join("")
lnonascii10 = lnonascii1 * 10
lnonascii100 = lnonascii10 * 10
lnonascii1000 = lnonascii100 * 10
ustr1 = [*"A".."Z",*"0".."9"].join("")
ustr10 = ustr1 * 10
ustr100 = ustr10 * 10
ustr1000 = ustr100 * 10
unonascii1 = [*"\u{c0}".."\u{df}"].join("")
unonascii10 = unonascii1 * 10
unonascii100 = unonascii10 * 10
unonascii1000 = unonascii100 * 10
benchmark:
casecmp_p-1: lstr1.casecmp?(ustr1)
casecmp_p-10: lstr10.casecmp?(ustr10)
casecmp_p-100: lstr100.casecmp?(ustr100)
casecmp_p-1000: lstr1000.casecmp?(ustr1000)
casecmp_p-nonascii1: lnonascii1.casecmp?(unonascii1)
casecmp_p-nonascii10: lnonascii10.casecmp?(unonascii10)
casecmp_p-nonascii100: lnonascii100.casecmp?(unonascii100)
casecmp_p-nonascii1000: lnonascii1000.casecmp?(unonascii1000)

View file

@ -3,8 +3,16 @@ prelude: |
str10 = str1 * 10
str100 = str10 * 10
str1000 = str100 * 10
nonascii1 = [*"\u{c0}".."\u{df}"].join("")
nonascii10 = nonascii1 * 10
nonascii100 = nonascii10 * 10
nonascii1000 = nonascii100 * 10
benchmark:
downcase-1: str1.upcase
downcase-10: str10.upcase
downcase-100: str100.upcase
downcase-1000: str1000.upcase
downcase-nonascii1: nonascii1.downcase
downcase-nonascii10: nonascii10.downcase
downcase-nonascii100: nonascii100.downcase
downcase-nonascii1000: nonascii1000.downcase

View file

@ -3,8 +3,16 @@ prelude: |
str10 = str1 * 10
str100 = str10 * 10
str1000 = str100 * 10
nonascii1 = [*"\u{c0}".."\u{cf}",*"\u{f0}".."\u{ff}"].join("")
nonascii10 = nonascii1 * 10
nonascii100 = nonascii10 * 10
nonascii1000 = nonascii100 * 10
benchmark:
swapcase-1: str1.swapcase
swapcase-10: str10.swapcase
swapcase-100: str100.swapcase
swapcase-1000: str1000.swapcase
swapcase-nonascii1: nonascii1.swapcase
swapcase-nonascii10: nonascii10.swapcase
swapcase-nonascii100: nonascii100.swapcase
swapcase-nonascii1000: nonascii1000.swapcase

View file

@ -3,8 +3,16 @@ prelude: |
str10 = str1 * 10
str100 = str10 * 10
str1000 = str100 * 10
nonascii1 = [*"\u{e0}".."\u{ff}"].join("")
nonascii10 = nonascii1 * 10
nonascii100 = nonascii10 * 10
nonascii1000 = nonascii100 * 10
benchmark:
upcase-1: str1.upcase
upcase-10: str10.upcase
upcase-100: str100.upcase
upcase-1000: str1000.upcase
upcase-nonascii1: nonascii1.upcase
upcase-nonascii10: nonascii10.upcase
upcase-nonascii100: nonascii100.upcase
upcase-nonascii1000: nonascii1000.upcase