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

Use String#start_with? and String#end_with? #99

Closed
azumakuniyuki opened this issue Dec 30, 2017 · 0 comments
Closed

Use String#start_with? and String#end_with? #99

azumakuniyuki opened this issue Dec 30, 2017 · 0 comments

Comments

@azumakuniyuki
Copy link
Member

ruby 2.4.3p205 (2017-12-14 revision 61247) [x86_64-darwin16]
Rehearsal ----------------------------------------------------------
String#start_with        0.790000   0.000000   0.790000 (  0.803203)
String#start_with(all)   0.780000   0.000000   0.780000 (  0.780285)
String#end_with(all)     0.790000   0.000000   0.790000 (  0.801215)
String#end_with          0.800000   0.010000   0.810000 (  0.800526)
String =~ /\A.../        1.550000   0.000000   1.550000 (  1.561355)
String =~ /...\z/        1.610000   0.010000   1.620000 (  1.621699)
String =~ /\A...\z/      1.640000   0.000000   1.640000 (  1.649723)
------------------------------------------------- total: 7.980000sec

                             user     system      total        real
String#start_with        0.740000   0.000000   0.740000 (  0.752940)
String#start_with(all)   0.830000   0.010000   0.840000 (  0.838893)
String#end_with(all)     0.830000   0.000000   0.830000 (  0.844759)
String#end_with          0.840000   0.000000   0.840000 (  0.845806)
String =~ /\A.../        1.520000   0.010000   1.530000 (  1.524290)
String =~ /...\z/        1.560000   0.000000   1.560000 (  1.576624)
String =~ /\A...\z/      1.600000   0.010000   1.610000 (  1.610818)
jruby 9.1.15.0 (2.3.3) 2017-12-07 929fde8 Java HotSpot(TM) 64-Bit Server VM 25.77-b03 on 1.8.0_77-b03 +jit [darwin-x86_64]
Rehearsal ----------------------------------------------------------
String#start_with        0.950000   0.030000   0.980000 (  0.336283)
String#start_with(all)   0.510000   0.010000   0.520000 (  0.227464)
String#end_with(all)     0.530000   0.010000   0.540000 (  0.226937)
String#end_with          0.450000   0.020000   0.470000 (  0.232159)
String =~ /\A.../        1.480000   0.060000   1.540000 (  0.850047)
String =~ /...\z/        0.920000   0.050000   0.970000 (  1.107115)
String =~ /\A...\z/      0.790000   0.020000   0.810000 (  0.622925)
------------------------------------------------- total: 5.830000sec

                             user     system      total        real
String#start_with        0.110000   0.000000   0.110000 (  0.106424)
String#start_with(all)   0.090000   0.010000   0.100000 (  0.084790)
String#end_with(all)     0.090000   0.000000   0.090000 (  0.099988)
String#end_with          0.130000   0.000000   0.130000 (  0.132520)
String =~ /\A.../        0.450000   0.020000   0.470000 (  0.522887)
String =~ /...\z/        0.490000   0.020000   0.510000 (  0.583060)
String =~ /\A...\z/      0.520000   0.020000   0.540000 (  0.545697)

https://github.com/azumakuniyuki/ruby-benchmark-collection/blob/master/string-start-or-end-with-vs-equal-tilde.rb

azumakuniyuki added a commit that referenced this issue Jan 9, 2018
… String#end_with? instead of =~ /\A...\z/
azumakuniyuki added a commit that referenced this issue Jan 15, 2018
…replaced with String#start_with?, String#end_with? or String#include? #99 #105
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant